From: Bernhard Voelker Date: Fri, 30 Nov 2012 16:12:12 +0000 (+0100) Subject: libmount: avoid endless loop in mnt_get_kernel_cmdline_option X-Git-Tag: v2.23-rc1~445 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c0ba1ce30311c690b738bdc19a08845cb8235c2;p=thirdparty%2Futil-linux.git libmount: avoid endless loop in mnt_get_kernel_cmdline_option The above function infloops when the name to search for can only be found at the beginning of /proc/cmdline but doesn't match, e.g. when searching for "ro" in "root=/dev/sda1 quiet vga=0x31a". * libmount/src/utils.c (mnt_get_kernel_cmdline_option): Replace while by for loop to ensure the pointer p is incremented. Signed-off-by: Bernhard Voelker --- diff --git a/libmount/src/utils.c b/libmount/src/utils.c index af6eb0b33a..8e6b147b8c 100644 --- a/libmount/src/utils.c +++ b/libmount/src/utils.c @@ -947,9 +947,7 @@ char *mnt_get_kernel_cmdline_option(const char *name) if (len && *(name + len - 1) == '=') val = 1; - while (p && *p) { - if (p != buf) - p++; + for ( ; p && *p; p++) { if (!(p = strstr(p, name))) break; /* not found the option */ if (p != buf && !isblank(*(p - 1)))