From 769f4d470877b1aab24af764968acd10708c66c6 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Thu, 9 Jul 2015 12:46:51 +0200 Subject: [PATCH] pcpserver.c: correctly return NOT_AUTHORIZED PCP error When trying to remove PCP Map when nonce is bad fixes #132 --- miniupnpd/pcpserver.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/miniupnpd/pcpserver.c b/miniupnpd/pcpserver.c index 57a5a77..dc468a9 100644 --- a/miniupnpd/pcpserver.c +++ b/miniupnpd/pcpserver.c @@ -1114,9 +1114,14 @@ static void DeletePCPMap(pcp_info_t *pcp_msg_info) index++) if(0 == strcmp(iaddr2, pcp_msg_info->mapped_str) && (proto2==proto) - && 0 == strcmp(desc, pcp_msg_info->desc) && ((iport2==iport) || (iport==0))) { - if (!pcp_msg_info->is_fw) { + if(0 != strcmp(desc, pcp_msg_info->desc)) { + /* nonce does not match */ + pcp_msg_info->result_code = PCP_ERR_NOT_AUTHORIZED; + syslog(LOG_ERR, "Unauthorized to remove PCP mapping internal port %hu, protocol %s", + iport, (pcp_msg_info->protocol == IPPROTO_TCP)?"TCP":"UDP"); + return; + } else if (!pcp_msg_info->is_fw) { r = _upnp_delete_redir(eport2, proto2); } else { #ifdef ENABLE_UPNPPINHOLE