]> granicus.if.org Git - curl/commitdiff
Song Ma found a memory leak in the if2ip code if you pass in an interface
authorDaniel Stenberg <daniel@haxx.se>
Thu, 12 Apr 2007 20:09:19 +0000 (20:09 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 12 Apr 2007 20:09:19 +0000 (20:09 +0000)
name longer than the name field of the ifreq struct (typically 6 bytes), as
then it wouldn't close the used dummy socket.

CHANGES
lib/if2ip.c

diff --git a/CHANGES b/CHANGES
index 344db759b3cb1946064e2ee6002e1fea1874b0e2..e82301db98663cd38f4094df9baea60ee3f1e74f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,12 @@
 
                                   Changelog
 
+Daniel S (12 April 2007)
+- Song Ma found a memory leak in the if2ip code if you pass in an interface
+  name longer than the name field of the ifreq struct (typically 6 bytes), as
+  then it wouldn't close the used dummy socket. Bug #1698974
+  (http://curl.haxx.se/bug/view.cgi?id=1698974)
+
 Version 7.16.2 (11 April 2007)
 
 Yang Tse (10 April 2007)
index b21727156c06391d45d5a494ea6d62c0be0147d7..02bc6b94add78694adff6e96413c19291def4813 100644 (file)
@@ -98,8 +98,10 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size)
     struct ifreq req;
     size_t len = strlen(interface);
     memset(&req, 0, sizeof(req));
-    if(len >= sizeof(req.ifr_name))
+    if(len >= sizeof(req.ifr_name)) {
+      sclose(dummy);
       return NULL; /* this can't be a fine interface name */
+    }
     memcpy(req.ifr_name, interface, len+1);
     req.ifr_addr.sa_family = AF_INET;
 #ifdef IOCTL_3_ARGS