Hello Max, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/4940

to look at the new patch set (#2).

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(-)


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

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: newpatchset
Gerrit-Change-Id: I883048cf2807e606c6481634dbd569fc12aed889
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofm...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msur...@sysmocom.de>

Reply via email to