teddy_bear
Joined: 04 Feb 2009 Posts: 4
|
Posted: Fri Mar 12, 2010 6:34 pm Post subject: Bug in miniupnpd 20100308: using invalid socket handlers |
|
|
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
|
|
|