[PATCH] libosmocore[master]: utils: avoid segfault when calling osmo_strlcpy(src=NULL)

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
Wed Oct 25 02:19:22 UTC 2017


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

utils: avoid segfault when calling osmo_strlcpy(src=NULL)

Change-Id: Ieba7ba262ace2e370a4b9a550b3131fb13f07413
---
M src/utils.c
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/07/4407/1

diff --git a/src/utils.c b/src/utils.c
index ef8e916..f5894d8 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -372,7 +372,7 @@
  */
 size_t osmo_strlcpy(char *dst, const char *src, size_t siz)
 {
-	size_t ret = strlen(src);
+	size_t ret = src ? strlen(src) : 0;
 
 	if (siz) {
 		size_t len = (ret >= siz) ? siz - 1 : ret;

-- 
To view, visit https://gerrit.osmocom.org/4407
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieba7ba262ace2e370a4b9a550b3131fb13f07413
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