miniupnp.tuxfamily.org Forum Index miniupnp.tuxfamily.org
The forum about miniupnp and libnatpmp
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Bug in miniupnpd 20100308: using invalid socket handlers

 
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpd Bugs
View previous topic :: View next topic  
Author Message
teddy_bear



Joined: 04 Feb 2009
Posts: 4

PostPosted: Fri Mar 12, 2010 6:34 pm    Post subject: Bug in miniupnpd 20100308: using invalid socket handlers Reply with quote

Found a bug in the latest 20100308 version.

When miniupnpd is compiled with ENABLE_NATPMP option, but NAT-PMP is turned off in the config file, the socket handlers in snatpmp array are not set to -1 by default.
As a result, the code tries to call recvfrom() on invalid socket handlers causing the flood of hundreds of error messages in the log per second, and hogging CPU.

The following simple fix resolved the problem for me:
Code:

diff --git miniupnpd/miniupnpd.c miniupnpd/miniupnpd.c
index 47e32bf..86901f9 100644
--- miniupnpd/miniupnpd.c
+++ miniupnpd/miniupnpd.c
@@ -1002,6 +1002,11 @@ main(int argc, char * * argv)
    memset(snotify, 0, sizeof(snotify));
    if(init(argc, argv, &v) != 0)
       return 1;
+#ifdef ENABLE_NATPMP
+   for (i=0; i<MAX_LAN_ADDR; i++) {
+      snatpmp[i] = -1;
+   }
+#endif
 
    LIST_INIT(&upnphttphead);
 #ifdef USE_MINIUPNPDCTL
Back to top
View user's profile Send private message
miniupnp
Site Admin


Joined: 14 Apr 2007
Posts: 1497

PostPosted: Sun Mar 14, 2010 12:25 am    Post subject: Reply with quote

thanks for the patch.
_________________
Main miniUPnP author.
http://miniupnp.tuxfamily.org/
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    miniupnp.tuxfamily.org Forum Index -> miniupnpd Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP
© 2007 Thomas Bernard, author of MiniUPNP.