From: Gaël PORTAY Date: Fri, 20 Mar 2020 20:21:58 +0000 (-0400) Subject: lib/mangle: check for the NULL string argument X-Git-Tag: v2.35.2~36 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=a41254b8f7e74a6c14f357af8b7ea9a457dffa89;p=thirdparty%2Futil-linux.git lib/mangle: check for the NULL string argument This patch prevents to call the function strlen() with a NULL string argument that leads to a segmentation fault. Signed-off-by: Gaël PORTAY --- diff --git a/include/mangle.h b/include/mangle.h index 0a4b60c1c8..08c66cb47f 100644 --- a/include/mangle.h +++ b/include/mangle.h @@ -14,12 +14,14 @@ extern char *unmangle(const char *s, const char **end); static inline void unmangle_string(char *s) { - unmangle_to_buffer(s, s, strlen(s) + 1); + if (s) + unmangle_to_buffer(s, s, strlen(s) + 1); } static inline void unhexmangle_string(char *s) { - unhexmangle_to_buffer(s, s, strlen(s) + 1); + if (s) + unhexmangle_to_buffer(s, s, strlen(s) + 1); } #endif /* UTIL_LINUX_MANGLE_H */