diff --git a/src/xpdev/gen_defs.h b/src/xpdev/gen_defs.h index be3a930fbb732201f03f628f5ff904038a61e1b9..b4a4858a90f032d9c57b6e8d39f426fa12e34b21 100644 --- a/src/xpdev/gen_defs.h +++ b/src/xpdev/gen_defs.h @@ -430,11 +430,7 @@ typedef struct { #define TERMINATE(str) str[sizeof(str)-1]=0 /* This is a bound-safe version of strcpy basically - only works with fixed-length arrays */ -#ifdef SAFECOPY_USES_SPRINTF -#define SAFECOPY(dst,src) sprintf(dst,"%.*s",(int)sizeof(dst)-1,src) -#else /* strncpy is faster */ -#define SAFECOPY(dst,src) (strncpy(dst,src,sizeof(dst)), TERMINATE(dst)) -#endif +#define SAFECOPY(dst,src) (strncpy(dst,(src)==NULL?"(null)":(src),sizeof(dst)), TERMINATE(dst)) #define SAFECAT(dst, src) do { \ if(strlen((char*)(dst)) + strlen((char*)(src)) < sizeof(dst)) { \