* In NETstring use memcpy to copy the string and guarantee NUL-termination manually

* strlcpy() is unsafe if we cannot trust the source string to be NUL-terminated (as strlcpy does "return strlen(src);")


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4242 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-03-23 13:50:54 +00:00
parent 6cd8e03773
commit cf6ea01b4a
1 changed files with 3 additions and 1 deletions

View File

@ -357,7 +357,9 @@ BOOL NETstring(char *str, uint16_t maxlen)
NetMsg.type, NetMsg.source, len, maxlen); NetMsg.type, NetMsg.source, len, maxlen);
len = maxlen; len = maxlen;
} }
strlcpy(str, store, len); memcpy(str, store, len);
// Guarantee NUL-termination
str[len - 1] = '\0';
} }
// Increment the size of the message // Increment the size of the message