* Add a doxygen comment to source:trunk/lib/framework/strlfuncs.h describing macro STR_L_FUNC_TRUNCATION_DETECT

* Replace (the last) strncpy() call in nettyps.c with a strlcpy() call


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@2647 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2007-10-27 20:20:35 +00:00
parent 49df8ea371
commit 0374c67a12
2 changed files with 13 additions and 3 deletions

View File

@ -24,6 +24,18 @@
#include <string.h>
#include <stddef.h>
/** \def STR_L_FUNC_TRUNCATION_DETECT
* The "original" strlcpy() and strlcat() functions will return the amount
* of characters the destination string would be long, if no truncation has
* occurred.
*
* When STR_L_FUNC_TRUNCATION_DETECT is defined this behaviour will be
* simulated.
*
* Right now though this behaviour isn't required, and as such it isn't
* compiled in by leaving STR_L_FUNC_TRUNCATION_DETECT undefined.
*/
#ifdef STR_L_FUNC_TRUNCATION_DETECT
static inline size_t strlcpy(char* dest, const char* src, size_t size)
#else

View File

@ -347,9 +347,7 @@ static void NETcoder(PACKETDIR dir)
int16_t i16 = -16;
int8_t i8 = -8;
strncpy(str, original, sizeof(str));
// Guarantee to nul-terminate
str[sizeof(str) - 1] = '\0';
strlcpy(str, original, sizeof(str));
NETbegin(0, dir);
NETbool(&b); assert(b == TRUE);