mirror of
https://github.com/curl/curl.git
synced 2026-08-25 04:13:32 +03:00
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.
This commit is contained in:
parent
ea74b4b8e1
commit
c38c339480
2 changed files with 9 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue