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

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
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 https://gerrit.osmocom.org/1588
To unsubscribe, visit https://gerrit.osmocom.org/settings

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



More information about the gerrit-log mailing list