1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-08 20:58:20 +03:00

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.
This commit is contained in:
Yu Watanabe 2021-12-24 05:03:16 +09:00 committed by GitHub
parent 10c8c32f13
commit 558ad6bd38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);