summaryrefslogtreecommitdiffstats
path: root/libmount/src/utils.c
diff options
context:
space:
mode:
authorBernhard Voelker2012-11-30 17:12:12 +0100
committerKarel Zak2012-12-10 13:15:19 +0100
commit2c0ba1ce30311c690b738bdc19a08845cb8235c2 (patch)
tree949e0f7aa3194e5529b3a0aa4a76c752c82ad505 /libmount/src/utils.c
parentrename: use macro to print version (diff)
downloadkernel-qcow2-util-linux-2c0ba1ce30311c690b738bdc19a08845cb8235c2.tar.gz
kernel-qcow2-util-linux-2c0ba1ce30311c690b738bdc19a08845cb8235c2.tar.xz
kernel-qcow2-util-linux-2c0ba1ce30311c690b738bdc19a08845cb8235c2.zip
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 <mail@bernhard-voelker.de>
Diffstat (limited to 'libmount/src/utils.c')
-rw-r--r--libmount/src/utils.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index af6eb0b33..8e6b147b8 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)))