pcpserver.c: correctly return NOT_AUTHORIZED PCP error

When trying to remove PCP Map when nonce is bad

fixes #132
This commit is contained in:
Thomas Bernard 2015-07-09 12:46:51 +02:00
parent 8d08346c60
commit 769f4d4708
1 changed files with 7 additions and 2 deletions

View File

@ -1114,9 +1114,14 @@ static void DeletePCPMap(pcp_info_t *pcp_msg_info)
index++) index++)
if(0 == strcmp(iaddr2, pcp_msg_info->mapped_str) if(0 == strcmp(iaddr2, pcp_msg_info->mapped_str)
&& (proto2==proto) && (proto2==proto)
&& 0 == strcmp(desc, pcp_msg_info->desc)
&& ((iport2==iport) || (iport==0))) { && ((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); r = _upnp_delete_redir(eport2, proto2);
} else { } else {
#ifdef ENABLE_UPNPPINHOLE #ifdef ENABLE_UPNPPINHOLE