Author: radek                        Date: Mon Nov  3 16:30:48 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- do not leak file descriptors if libnet_init() called with device=NULL 
(libnet_ifaddrlist())

---- Files affected:
SOURCES:
   libnet-leaking-fd.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/libnet-leaking-fd.patch
diff -u /dev/null SOURCES/libnet-leaking-fd.patch:1.1
--- /dev/null   Mon Nov  3 17:30:49 2008
+++ SOURCES/libnet-leaking-fd.patch     Mon Nov  3 17:30:43 2008
@@ -0,0 +1,62 @@
+--- libnet/src/libnet_if_addr.c.bak    2008-11-03 17:06:55.493985477 +0100
++++ libnet/src/libnet_if_addr.c        2008-11-03 17:07:07.317325455 +0100
+@@ -141,6 +141,7 @@
+       snprintf(errbuf, LIBNET_ERRBUF_SIZE,
+                 "%s(): fopen(proc_dev_file) failed: %s\n",  __func__,
+                 strerror(errno));
++      close(fd);
+       return (-1);
+     }
+ #endif
+@@ -154,6 +155,10 @@
+       snprintf(errbuf, LIBNET_ERRBUF_SIZE,
+                 "%s(): ioctl(SIOCGIFCONF) error: %s\n", 
+                 __func__, strerror(errno));
++      close(fd);
++#ifdef HAVE_LINUX_PROCFS
++      fclose(fp);
++#endif
+       return(-1);
+     }
+ 
+@@ -213,7 +218,7 @@
+             pifr = ifr;
+             continue;
+       }
+-      
++
+         strncpy(nifr.ifr_name, device, sizeof(device) - 1);
+         nifr.ifr_name[sizeof(nifr.ifr_name) - 1] = '\0';
+         if (ioctl(fd, SIOCGIFADDR, (int8_t *)&nifr) < 0)
+@@ -224,6 +229,9 @@
+                         "%s(): SIOCGIFADDR: dev=%s: %s\n", __func__, device,
+                         strerror(errno));
+                 close(fd);
++#ifdef HAVE_LINUX_PROCFS
++                fclose(fp);
++#endif
+                 return (-1);
+           }
+             else /* device has no IP address => set to 0 */
+@@ -240,6 +248,10 @@
+         {
+             snprintf(errbuf, LIBNET_ERRBUF_SIZE, 
+                     "%s(): strdup not enough memory\n", __func__);
++            close(fd);
++#ifndef HAVE_LINUX_PROCFS
++            fclose(fp);
++#endif
+             return(-1);
+         }
+ 
+@@ -251,7 +263,9 @@
+ #endif
+ 
+     } /* while|for */
+-      
++
++    close(fd);
++
+ #ifdef HAVE_LINUX_PROCFS
+     if (ferror(fp))
+     {
================================================================
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to