Browse Source

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>
pull/989/head
Gaël PORTAY 2 years ago
parent
commit
e368d0ad5d
  1. 6
      include/mangle.h

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

Loading…
Cancel
Save