aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Santos <[email protected]>2010-07-21 11:15:21 -0400
committerBjörn Gustavsson <[email protected]>2010-07-26 14:42:14 +0200
commitcfcb9626d95640e42972c2284c08b61240f11d0c (patch)
tree38db3c757a0b96d95d8d2c3505183829bd2e72c2
parenta2fb9485642c174117e6fe09189a53d2c510bb14 (diff)
downloadotp-cfcb9626d95640e42972c2284c08b61240f11d0c.tar.gz
otp-cfcb9626d95640e42972c2284c08b61240f11d0c.tar.bz2
otp-cfcb9626d95640e42972c2284c08b61240f11d0c.zip
inet: null terminate ifr_name buffer
The buffer holding the interface name should be null terminated. See man 7 socket on Linux or the definition of IFNAMSIZ in net/if.h on FreeBSD: Length of interface external name, including terminating '\0'.
-rw-r--r--erts/emulator/drivers/common/inet_drv.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c
index 0ea54930ba..9ad6e4a845 100644
--- a/erts/emulator/drivers/common/inet_drv.c
+++ b/erts/emulator/drivers/common/inet_drv.c
@@ -4103,7 +4103,7 @@ static int inet_ctl_ifget(inet_descriptor* desc, char* buf, int len,
goto error;
sys_memset(ifreq.ifr_name, '\0', IFNAMSIZ);
sys_memcpy(ifreq.ifr_name, buf+1,
- (namlen > IFNAMSIZ) ? IFNAMSIZ : namlen);
+ (namlen >= IFNAMSIZ) ? IFNAMSIZ-1 : namlen);
buf += (namlen+1);
len -= (namlen+1);
sptr = sbuf;
@@ -4256,7 +4256,7 @@ static int inet_ctl_ifset(inet_descriptor* desc, char* buf, int len,
goto error;
sys_memset(ifreq.ifr_name, '\0', IFNAMSIZ);
sys_memcpy(ifreq.ifr_name, buf+1,
- (namlen > IFNAMSIZ) ? IFNAMSIZ : namlen);
+ (namlen >= IFNAMSIZ) ? IFNAMSIZ-1 : namlen);
buf += (namlen+1);
len -= (namlen+1);