diff options
author | Helmut Grohne <helmut@subdivi.de> | 2010-01-19 20:24:19 +0100 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-01-19 18:39:39 +0000 |
commit | 67e82f1a0bc2a9078cfe11e0add190fa7cc4b891 (patch) | |
tree | ec2f2134d4c6b1a037c18fb65bdd3ef18a4efb8e /src/map/chrif.c | |
parent | abe96e3b05a99a984d6f00098f1aa9759814b542 (diff) | |
download | tmwa-67e82f1a0bc2a9078cfe11e0add190fa7cc4b891.tar.gz tmwa-67e82f1a0bc2a9078cfe11e0add190fa7cc4b891.tar.bz2 tmwa-67e82f1a0bc2a9078cfe11e0add190fa7cc4b891.tar.xz tmwa-67e82f1a0bc2a9078cfe11e0add190fa7cc4b891.zip |
fixed a few buffer overruns
strncpy does not always terminate strings. Unterminated strings
(without a length) are bad. So better terminate them.
Diffstat (limited to 'src/map/chrif.c')
-rw-r--r-- | src/map/chrif.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c index c4a528b..1f5673a 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -51,7 +51,8 @@ static int chrif_state; */ void chrif_setuserid (char *id) { - strncpy (userid, id, 24); + strncpy (userid, id, sizeof(userid)-1); + userid[sizeof(userid)-1] = '\0'; } /*========================================== @@ -60,7 +61,8 @@ void chrif_setuserid (char *id) */ void chrif_setpasswd (char *pwd) { - strncpy (passwd, pwd, 24); + strncpy (passwd, pwd, sizeof(passwd)-1); + passwd[sizeof(passwd)-1] = '\0'; } /*========================================== @@ -69,7 +71,8 @@ void chrif_setpasswd (char *pwd) */ void chrif_setip (char *ip) { - strncpy (char_ip_str, ip, 16); + strncpy (char_ip_str, ip, sizeof(char_ip_str)-1); + char_ip_str[sizeof(char_ip_str)-1] = '\0'; char_ip = inet_addr (char_ip_str); } |