summaryrefslogtreecommitdiff
path: root/src/analyze/analyze-verify.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-12-24 05:03:16 +0900
committerGitHub <noreply@github.com>2021-12-23 21:03:16 +0100
commit558ad6bd3855834c74adea8b3f22bb8e3dc514f9 (patch)
treea683dc5f94e46005d324521cadd4b655347c9acd /src/analyze/analyze-verify.c
parent10c8c32f1391bbf414cf47ed863288328e985790 (diff)
downloadsystemd-558ad6bd3855834c74adea8b3f22bb8e3dc514f9.tar.gz
analyze: fix segfault when malloc() fails (#21874)
Fixes #21872. log_syntax_callback sets 's', a.k.a. '*userdata', to POINTER_MAX to signal allocation failure. If the error does not cause immediate failure of the program, and log_syntax_callback is called again, it would try to use 's' as a pointer to a set and fail badly.
Diffstat (limited to 'src/analyze/analyze-verify.c')
-rw-r--r--src/analyze/analyze-verify.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/analyze/analyze-verify.c b/src/analyze/analyze-verify.c
index f3e5d3530d..943a1f27de 100644
--- a/src/analyze/analyze-verify.c
+++ b/src/analyze/analyze-verify.c
@@ -26,6 +26,9 @@ static void log_syntax_callback(const char *unit, int level, void *userdata) {
if (level > LOG_WARNING)
return;
+ if (*s == POINTER_MAX)
+ return;
+
r = set_put_strdup(s, unit);
if (r < 0) {
set_free_free(*s);