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.orgNeels Hofmeyr has submitted this change and it was merged.
Change subject: osmo_strlcpy: sanitize: don't memcpy from NULL src even if len is 0
......................................................................
osmo_strlcpy: sanitize: don't memcpy from NULL src even if len is 0
Some callers pass NULL and len == 0. The semantics are that we then
nul-terminate an emtpy string. Avoid a sanitizer warning by not calling
memcpy() for the NULL case.
Change-Id: I883048cf2807e606c6481634dbd569fc12aed889
---
M src/utils.c
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
  Max: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified
diff --git a/src/utils.c b/src/utils.c
index f63ff89..bc5329d 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -385,7 +385,8 @@
 
 	if (siz) {
 		size_t len = (ret >= siz) ? siz - 1 : ret;
-		memcpy(dst, src, len);
+		if (src)
+			memcpy(dst, src, len);
 		dst[len] = '\0';
 	}
 	return ret;
-- 
To view, visit https://gerrit.osmocom.org/4940
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I883048cf2807e606c6481634dbd569fc12aed889
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>