aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2007-04-12 20:09:19 +0000
committerDaniel Stenberg <daniel@haxx.se>2007-04-12 20:09:19 +0000
commitc38c33948067a3e2a170d337d940f7e27423ae07 (patch)
tree66208c5a218c65cd72945a5007fb07c8550fc45f /lib
parentea74b4b8e10b8fca1938435393b3a177566103cf (diff)
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/if2ip.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/if2ip.c b/lib/if2ip.c
index b21727156..02bc6b94a 100644
--- a/lib/if2ip.c
+++ b/lib/if2ip.c
@@ -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