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 <gael.portay@collabora.com>
This commit is contained in:
Gaël PORTAY 2020-03-20 16:21:58 -04:00
parent 3468dda9c3
commit e368d0ad5d
1 changed files with 4 additions and 2 deletions

View File

@ -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 */