>From 4ddf21607847570e1da3b692276f2a8242bd5af6 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker <mail@xxxxxxxxxxxxxxxxxxx> Date: Fri, 30 Nov 2012 17:12:12 +0100 Subject: [PATCH] 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@xxxxxxxxxxxxxxxxxxx> --- libmount/src/utils.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/libmount/src/utils.c b/libmount/src/utils.c index 74c3ad5..be242d0 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))) -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html