On Mon, 23 Aug 2021, Tkaczyk, Mariusz wrote: > On 19.08.2021 15:10, Nigel Croxon wrote: > > > + memset(ve->name, '\0', sizeof(ve->name)); > > + if (name) { > > + int l = strlen(ve->name); > > + if (l > 16) > > + l = 16; > > + memcpy(ve->name, name, l); > > + } > > What about: > if (name) > /* > * Name might not be null terminated. > */ > strncpy(ve->name, name, sizeof(ve->name)); I really like the idea of using strncpy(). I didn't realize it would nul-pad to the full size, and that is exactly what we want. So strncpy(ve->name, name?:"", sizeof(ve->name)); would be a complete solution. Thanks, NeilBrown