From: Lennart Poettering Date: Tue, 2 Jul 2024 14:01:28 +0000 (+0200) Subject: efi: fix mangle_stub_cmdline() for empty strings X-Git-Tag: v257-rc1~967^2~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d30b89c7fc46d87774fd6eb6770c1e024b97395c;p=thirdparty%2Fsystemd.git efi: fix mangle_stub_cmdline() for empty strings --- diff --git a/src/boot/efi/util.c b/src/boot/efi/util.c index 3639afcb15d..aafaf06e98b 100644 --- a/src/boot/efi/util.c +++ b/src/boot/efi/util.c @@ -42,19 +42,17 @@ static bool shall_be_whitespace(char16_t c) { } char16_t* mangle_stub_cmdline(char16_t *cmdline) { - char16_t *p, *q, *e; - if (!cmdline) return cmdline; - p = q = cmdline; - /* Skip initial whitespace */ - while (shall_be_whitespace(*p)) + const char16_t *p = cmdline; + while (*p != 0 && shall_be_whitespace(*p)) p++; /* Turn inner control characters into proper spaces */ - for (e = p; *p != 0; p++) { + char16_t *e = cmdline; + for (char16_t *q = cmdline; *p != 0; p++) { if (shall_be_whitespace(*p)) { *(q++) = ' '; continue;