[PATCH] libosmocore[master]: osmo_strlcpy: sanitize: don't memcpy from NULL src even if l...

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
Tue Nov 21 01:31:30 UTC 2017


Review at  https://gerrit.osmocom.org/4940

osmo_strlcpy: sanitize: don't memcpy from NULL src even if len is 0

Change-Id: I883048cf2807e606c6481634dbd569fc12aed889
---
M src/utils.c
1 file changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/40/4940/1

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: newchange
Gerrit-Change-Id: I883048cf2807e606c6481634dbd569fc12aed889
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list