Skip to content
Snippets Groups Projects
Commit 1e3a6b84 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Revert "Make SAFECOPY() even safer by not passing NULL destination to strncpy()"

This reverts commit c0e857c9.
parent a2b41984
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #3682 passed
......@@ -430,7 +430,11 @@ 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 */
#define SAFECOPY(dst,src) (strncpy(dst,(src)==NULL?"(null)":(src),sizeof(dst)), TERMINATE(dst))
#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 SAFECAT(dst, src) do { \
if(strlen((char*)(dst)) + strlen((char*)(src)) < sizeof(dst)) { \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment