openbsc[master]: add strncpy0.h for safe/convenient strncpy() wrappers

Neels Hofmeyr gerrit-no-reply at
Fri Jan 13 12:20:16 UTC 2017

Patch Set 2:

> Also, why not use strncat? if(sizeof(dst)) { *dst = '\0';
 > strncat(dst, src, sizeof(dst)-1); } looks easier to me.

Ah, the 'if (len)' check should definitely be in there.
Otherwise, using strncat is possible, never thought of it because
all of the code was using strncpy(); dest[n-1] = '\0'

strncpy() doesn't first go and find out the strlen to jump to the end,
but agreed that with *dst = '\0' that would probably be optimized away.

To view, visit
To unsubscribe, visit

Gerrit-MessageType: comment
Gerrit-Change-Id: I505d58a02fe46d492087a3dcbff59e287521d5ad
Gerrit-PatchSet: 2
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at>
Gerrit-HasComments: No

More information about the gerrit-log mailing list