util-linux/lib-mangle-check-for-the-NULL-string-argument.patch

41 lines
1.1 KiB
Diff

From e368d0ad5da392d35afdff8699089346e824d7ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ga=C3=ABl=20PORTAY?= <gael.portay@collabora.com>
Date: Fri, 20 Mar 2020 16:21:58 -0400
Subject: [PATCH 152/389] lib/mangle: check for the NULL string argument
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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>
---
include/mangle.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/mangle.h b/include/mangle.h
index 0a4b60c..08c66cb 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 */
--
1.8.3.1