Change in libosmocore[master]: osmo_strlcpy: Avoid calling memcpy with size=0

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/.

pespin gerrit-no-reply at lists.osmocom.org
Mon Sep 21 15:13:55 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/20230 )


Change subject: osmo_strlcpy: Avoid calling memcpy with size=0
......................................................................

osmo_strlcpy: Avoid calling memcpy with size=0

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



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/30/20230/1

diff --git a/src/utils.c b/src/utils.c
index 3c4a8c9..168f85f 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -545,7 +545,7 @@
 
 /*! Generic big-endian encoding of big endian number up to 64bit
  *  \param[in] value unsigned integer value to be stored
- *  \param[in] data_len number of octets 
+ *  \param[in] data_len number of octets
  *  \returns static buffer containing big-endian stored value
  *
  * This is like osmo_store64be_ext, except that this returns a static buffer of
@@ -577,7 +577,7 @@
 
 	if (siz) {
 		size_t len = (ret >= siz) ? siz - 1 : ret;
-		if (src)
+		if (len)
 			memcpy(dst, src, len);
 		dst[len] = '\0';
 	}

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/20230
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ic84af86d33c8a20f06036b13d0a10cf312582f0d
Gerrit-Change-Number: 20230
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200921/a21c4e49/attachment.htm>


More information about the gerrit-log mailing list