]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: avoid endless loop in mnt_get_kernel_cmdline_option
authorBernhard Voelker <mail@bernhard-voelker.de>
Fri, 30 Nov 2012 16:12:12 +0000 (17:12 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 10 Dec 2012 12:15:19 +0000 (13:15 +0100)
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 <mail@bernhard-voelker.de>
libmount/src/utils.c

index af6eb0b33aab91432473a6ff8221ba76a0e2ed55..8e6b147b8c772690c20015b9f7b69454faef349c 100644 (file)
@@ -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)))