aboutsummaryrefslogtreecommitdiff
path: root/lib/if2ip.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-06-30 11:48:19 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-06-30 11:48:19 +0000
commit4af08a19f85c577d9b1f2df892c82e34e473f31d (patch)
tree4ca5f208bb6c84b203f385ca6113c3598f7a3f1e /lib/if2ip.c
parentc14650caec03669b80324854c0a70dcc5301e59c (diff)
passing in a very long interface name could make a buffer overflow
Diffstat (limited to 'lib/if2ip.c')
-rw-r--r--lib/if2ip.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/if2ip.c b/lib/if2ip.c
index 237d1f758..b167b8df6 100644
--- a/lib/if2ip.c
+++ b/lib/if2ip.c
@@ -94,8 +94,11 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size)
}
else {
struct ifreq req;
+ size_t len = strlen(interface);
memset(&req, 0, sizeof(req));
- strcpy(req.ifr_name, interface);
+ if(len >= sizeof(req.ifr_name))
+ 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
if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) {