[MERGED] 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
Fri Oct 27 00:07:30 UTC 2017


Neels Hofmeyr has submitted this change and it was merged.

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


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

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

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified

Objections:
  Max: I would prefer this is not merged as is



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: merged
Gerrit-Change-Id: Ieba7ba262ace2e370a4b9a550b3131fb13f07413
Gerrit-PatchSet: 1
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>



More information about the gerrit-log mailing list