From bcf9f23456b58e4c959d84bb42d325589c3669ee Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 25 Oct 2017 04:16:45 +0200 Subject: utils: avoid segfault when calling osmo_strlcpy(src=NULL) Change-Id: Ieba7ba262ace2e370a4b9a550b3131fb13f07413 --- src/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/utils.c b/src/utils.c index ef8e916e..f5894d89 100644 --- a/src/utils.c +++ b/src/utils.c @@ -372,7 +372,7 @@ uint8_t *osmo_encode_big_endian(uint64_t value, size_t data_len) */ 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; -- cgit v1.2.3