From 5f68e74b6a795c5e3e1a6b3be3db85dfcd6b68c2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 14 Nov 2014 18:02:30 +0100 Subject: [PATCH] kmod-setup: improve for "kdbus" word on the kernel cmdline We really shouldn't check for words with "strstr()"... --- src/core/kmod-setup.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c index 23df1fdf3..fd0a0e06a 100644 --- a/src/core/kmod-setup.c +++ b/src/core/kmod-setup.c @@ -50,11 +50,24 @@ static void systemd_kmod_log( static bool cmdline_check_kdbus(void) { _cleanup_free_ char *line = NULL; + const char *p; + int r; - if (proc_cmdline(&line) < 0) + r = proc_cmdline(&line); + if (r < 0) return false; - return strstr(line, "kdbus") != NULL; + p = line; + for (;;) { + _cleanup_free_ char *word = NULL; + + r = unquote_first_word(&p, &word, true); + if (r <= 0) + return false; + + if (streq(word, "kdbus")) + return true; + } } #endif -- 2.30.2