From 9ee74defc83df0219afcabf3502496aaf84ed439 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Sun, 5 Feb 2012 00:40:50 +0100 Subject: [PATCH] Compile miniupnpd OK with -ansi flag. --- miniupnpd/Changelog.txt | 5 ++++- miniupnpd/linux/ifacewatcher.c | 6 +++--- miniupnpd/miniupnpd.c | 34 +++++++++++++++++-------------- miniupnpd/miniupnpdctl.c | 6 +++--- miniupnpd/natpmp.c | 4 ++-- miniupnpd/netfilter/iptcrdr.c | 4 ++-- miniupnpd/testupnpdescgen.c | 4 ++-- miniupnpd/upnpsoap.c | 37 +++++++++++++++++++--------------- 8 files changed, 56 insertions(+), 44 deletions(-) diff --git a/miniupnpd/Changelog.txt b/miniupnpd/Changelog.txt index aaff14d..de07c76 100644 --- a/miniupnpd/Changelog.txt +++ b/miniupnpd/Changelog.txt @@ -1,4 +1,7 @@ -$Id: Changelog.txt,v 1.252 2012/02/04 23:05:20 nanard Exp $ +$Id: Changelog.txt,v 1.253 2012/02/04 23:34:38 nanard Exp $ + +2012/02/05: + Compile ok with -ansi flag. 2012/02/04: Added friendl_name= option to config file diff --git a/miniupnpd/linux/ifacewatcher.c b/miniupnpd/linux/ifacewatcher.c index 3674b66..a82541a 100644 --- a/miniupnpd/linux/ifacewatcher.c +++ b/miniupnpd/linux/ifacewatcher.c @@ -1,7 +1,7 @@ -/* $Id: ifacewatcher.c,v 1.2 2011/07/30 13:11:39 nanard Exp $ */ +/* $Id: ifacewatcher.c,v 1.3 2012/02/04 23:34:40 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2009 Thomas Bernard + * (c) 2006-2012 Thomas Bernard * * ifacewatcher.c * @@ -239,7 +239,7 @@ ProcessInterfaceWatchNotify(int s) struct ifaddrmsg *ifa; int len; - struct rtattr *rth; // + struct rtattr *rth; int rtl; unsigned int ext_if_name_index = 0; diff --git a/miniupnpd/miniupnpd.c b/miniupnpd/miniupnpd.c index 0bf1b62..9ea1d84 100644 --- a/miniupnpd/miniupnpd.c +++ b/miniupnpd/miniupnpd.c @@ -1,4 +1,4 @@ -/* $Id: miniupnpd.c,v 1.141 2012/02/04 23:05:22 nanard Exp $ */ +/* $Id: miniupnpd.c,v 1.142 2012/02/04 23:34:39 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2012 Thomas Bernard @@ -193,32 +193,32 @@ OpenAndConfNFqueue(){ inet_pton(AF_INET, "239.255.255.250", &(ssdp.sin_addr)); - //Get a queue connection handle from the module + /* Get a queue connection handle from the module */ if (!(nfqHandle = nfq_open())) { syslog(LOG_ERR, "Error in nfq_open(): %m"); return -1; } - //Unbind the handler from processing any IP packets - // Not totally sure why this is done, or if it's necessary... + /* Unbind the handler from processing any IP packets + Not totally sure why this is done, or if it's necessary... */ if ((e = nfq_unbind_pf(nfqHandle, AF_INET)) < 0) { syslog(LOG_ERR, "Error in nfq_unbind_pf(): %m"); return -1; } - //Bind this handler to process IP packets... + /* Bind this handler to process IP packets... */ if (nfq_bind_pf(nfqHandle, AF_INET) < 0) { syslog(LOG_ERR, "Error in nfq_bind_pf(): %m"); return -1; } - // Install a callback on queue -Q + /* Install a callback on queue -Q */ if (!(myQueue = nfq_create_queue(nfqHandle, nfqueue, &nfqueue_cb, NULL))) { syslog(LOG_ERR, "Error in nfq_create_queue(): %m"); return -1; } - // Turn on packet copy mode + /* Turn on packet copy mode */ if (nfq_set_mode(myQueue, NFQNL_COPY_PACKET, 0xffff) < 0) { syslog(LOG_ERR, "Error setting packet copy mode (): %m"); return -1; @@ -289,7 +289,8 @@ static int nfqueue_cb( } else { syslog(LOG_ERR,"nfq_get_msg_packet_hdr failed"); - return 1; // from nfqueue source: 0 = ok, >0 = soft error, <0 hard error + return 1; + /* from nfqueue source: 0 = ok, >0 = soft error, <0 hard error */ } return 0; @@ -1075,7 +1076,7 @@ main(int argc, char * * argv) int sudpv6 = -1; /* IP v6 socket for receiving SSDP */ #endif #ifdef ENABLE_NATPMP - int * snatpmp; + int * snatpmp = NULL; #endif #ifdef ENABLE_NFQUEUE int nfqh = -1; @@ -1084,7 +1085,7 @@ main(int argc, char * * argv) int sifacewatcher = -1; #endif - int * snotify; + int * snotify = NULL; int addr_count; LIST_HEAD(httplisthead, upnphttp) upnphttphead; struct upnphttp * e = 0; @@ -1114,12 +1115,15 @@ main(int argc, char * * argv) addr_count = 0; for(lan_addr = lan_addrs.lh_first; lan_addr != NULL; lan_addr = lan_addr->list.le_next) addr_count++; - snotify = (int*) malloc(addr_count * sizeof(int)); - memset(snotify, 0, sizeof(snotify)); + if(addr_count > 0) { + snotify = calloc(addr_count, sizeof(int)); + } #ifdef ENABLE_NATPMP - snatpmp = (int*) malloc(addr_count * sizeof(int)); - for(i = 0; i < addr_count; i++) - snatpmp[i] = -1; + if(addr_count > 0) { + snatpmp = malloc(addr_count * sizeof(int)); + for(i = 0; i < addr_count; i++) + snatpmp[i] = -1; + } #endif LIST_INIT(&upnphttphead); diff --git a/miniupnpd/miniupnpdctl.c b/miniupnpd/miniupnpdctl.c index 6c5c83a..c9f9939 100644 --- a/miniupnpd/miniupnpdctl.c +++ b/miniupnpd/miniupnpdctl.c @@ -1,7 +1,7 @@ -/* $Id: miniupnpdctl.c,v 1.8 2010/02/15 10:19:46 nanard Exp $ */ +/* $Id: miniupnpdctl.c,v 1.9 2012/02/04 23:34:39 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006 Thomas Bernard + * (c) 2006-2012 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -31,7 +31,7 @@ main(int argc, char * * argv) int s; struct sockaddr_un addr; -// signal(SIGINT, sighandler); + /*signal(SIGINT, sighandler);*/ s = socket(AF_UNIX, SOCK_STREAM, 0); if(s<0) { diff --git a/miniupnpd/natpmp.c b/miniupnpd/natpmp.c index cafd404..b9cad59 100644 --- a/miniupnpd/natpmp.c +++ b/miniupnpd/natpmp.c @@ -1,4 +1,4 @@ -/* $Id: natpmp.c,v 1.27 2012/02/01 11:13:30 nanard Exp $ */ +/* $Id: natpmp.c,v 1.28 2012/02/04 23:34:39 nanard Exp $ */ /* MiniUPnP project * (c) 2007-2012 Thomas Bernard * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ @@ -38,7 +38,7 @@ int OpenAndConfNATPMPSocket(in_addr_t addr) memset(&natpmp_addr, 0, sizeof(natpmp_addr)); natpmp_addr.sin_family = AF_INET; natpmp_addr.sin_port = htons(NATPMP_PORT); - //natpmp_addr.sin_addr.s_addr = INADDR_ANY; + /*natpmp_addr.sin_addr.s_addr = INADDR_ANY; */ natpmp_addr.sin_addr.s_addr = addr; if(bind(snatpmp, (struct sockaddr *)&natpmp_addr, sizeof(natpmp_addr)) < 0) { diff --git a/miniupnpd/netfilter/iptcrdr.c b/miniupnpd/netfilter/iptcrdr.c index d461826..f256fc2 100644 --- a/miniupnpd/netfilter/iptcrdr.c +++ b/miniupnpd/netfilter/iptcrdr.c @@ -1,4 +1,4 @@ -/* $Id: iptcrdr.c,v 1.46 2011/07/30 13:14:36 nanard Exp $ */ +/* $Id: iptcrdr.c,v 1.47 2012/02/04 23:34:41 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2011 Thomas Bernard @@ -278,7 +278,7 @@ get_redirect_rule(const char * ifname, unsigned short eport, int proto, continue; } target = (void *)e + e->target_offset; - //target = ipt_get_target(e); + /* target = ipt_get_target(e); */ mr = (const struct ip_nat_multi_range *)&target->data[0]; snprintip(iaddr, iaddrlen, ntohl(mr->range[0].min_ip)); *iport = ntohs(mr->range[0].min.all); diff --git a/miniupnpd/testupnpdescgen.c b/miniupnpd/testupnpdescgen.c index ba276f5..07bb208 100644 --- a/miniupnpd/testupnpdescgen.c +++ b/miniupnpd/testupnpdescgen.c @@ -1,4 +1,4 @@ -/* $Id: testupnpdescgen.c,v 1.26 2012/02/04 23:05:21 nanard Exp $ */ +/* $Id: testupnpdescgen.c,v 1.27 2012/02/04 23:34:39 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2012 Thomas Bernard @@ -84,7 +84,7 @@ xml_pretty_print(const char * s, int len, FILE * f) if(elt_close==1) { /*fputc('\n', f); n++; */ - //elt_close = 0; + /* elt_close = 0; */ if(indent > 0) indent--; } diff --git a/miniupnpd/upnpsoap.c b/miniupnpd/upnpsoap.c index cb634a4..f0bf7dc 100644 --- a/miniupnpd/upnpsoap.c +++ b/miniupnpd/upnpsoap.c @@ -1,7 +1,7 @@ -/* $Id: upnpsoap.c,v 1.89 2012/01/20 21:45:58 nanard Exp $ */ +/* $Id: upnpsoap.c,v 1.90 2012/02/04 23:34:40 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2011 Thomas Bernard + * (c) 2006-2012 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -1147,8 +1147,7 @@ CheckStatus(struct upnphttp * h) static int DataVerification(struct upnphttp * h, char * int_ip, unsigned short * int_port, const char * protocol, char * leaseTime) { - //int n; - // ** Internal IP can't be wildcarded + /* ** Internal IP can't be wildcarded */ if (!int_ip) { SoapError(h, 708, "WildCardNotPermittedInSrcIP"); @@ -1161,16 +1160,17 @@ DataVerification(struct upnphttp * h, char * int_ip, unsigned short * int_port, return 0; } - // ** Internal port can't be wilcarded. -// printf("\tint_port: *%d*\n", *int_port); + /* ** Internal port can't be wilcarded. */ +/* printf("\tint_port: *%d*\n", *int_port); */ if (*int_port == 0) { SoapError(h, 706, "InternalPortWilcardingNotAllowed"); return 0; } - // ** Protocol can't be wilcarded and can't be an unknown port (here deal with only UDP, TCP, UDPLITE) -// printf("\tprotocol: *%s*\n", protocol); + /* ** Protocol can't be wilcarded and can't be an unknown port + * (here deal with only UDP, TCP, UDPLITE) */ +/* printf("\tprotocol: *%s*\n", protocol); */ if (atoi(protocol) == 65535) { SoapError(h, 707, "ProtocolWilcardingNotAllowed"); @@ -1187,8 +1187,8 @@ DataVerification(struct upnphttp * h, char * int_ip, unsigned short * int_port, return 0; } - // ** Lease Time can't be wilcarded nor >86400. -// printf("\tlease time: %s\n", leaseTime); + /* ** Lease Time can't be wilcarded nor >86400. */ +/* printf("\tlease time: %s\n", leaseTime); */ if(!leaseTime || !atoi(leaseTime) || atoi(leaseTime)>86400) { /* lease duration is never infinite, nor wilcarded. In this case, use default value */ @@ -1355,7 +1355,8 @@ AddPinhole(struct upnphttp * h, const char * action) rport = (unsigned short)atoi(rem_port); iport = (unsigned short)atoi(int_port); - // ** As there is no security policy, InternalClient must be equal to the CP's IP address. + /* ** As there is no security policy, InternalClient must be equal + * to the CP's IP address. */ if(DataVerification(h, int_ip, &iport, protocol, leaseTime) == 0 || PinholeVerification(h, int_ip, &iport) <= 0) { @@ -1363,7 +1364,7 @@ AddPinhole(struct upnphttp * h, const char * action) return ; } - // ** RemoteHost can be wilcarded or an IDN. + /* ** RemoteHost can be wilcarded or an IDN. */ /*printf("\trem_host: %s\n", rem_host);*/ if (rem_host!=NULL && !strchr(rem_host, ':')) { @@ -1420,7 +1421,8 @@ UpdatePinhole(struct upnphttp * h, const char * action) return; } - // Check that client is not deleting an pinhole he doesn't have access to, because of its public access + /* Check that client is not deleting an pinhole + * it doesn't have access to, because of its public access */ n = upnp_get_pinhole_info(0, 0, iaddr, &iport, proto, uid, lt); if (n > 0) { @@ -1529,7 +1531,8 @@ DeletePinhole(struct upnphttp * h, const char * action) return; } - // Check that client is not deleting an pinhole he doesn't have access to, because of its public access + /* Check that client is not deleting an pinhole + * it doesn't have access to, because of its public access */ n = upnp_get_pinhole_info(0, 0, iaddr, &iport, proto, uid, lt); if (n > 0) { @@ -1591,7 +1594,8 @@ CheckPinholeWorking(struct upnphttp * h, const char * action) return; } - // Check that client is not checking a pinhole he doesn't have access to, because of its public access + /* Check that client is not checking a pinhole + * it doesn't have access to, because of its public access */ r = upnp_get_pinhole_info(eaddr, eport, iaddr, &iport, proto, uid, lt); if (r > 0) { @@ -1688,7 +1692,8 @@ GetPinholePackets(struct upnphttp * h, const char * action) return; } - // Check that client is not getting infos of a pinhole he doesn't have access to, because of its public access + /* Check that client is not getting infos of a pinhole + * it doesn't have access to, because of its public access */ r = upnp_get_pinhole_info(0, 0, iaddr, &iport, proto, uid, lt); if (r > 0) {