public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libmount: avoid endless loop in, mnt_get_kernel_cmdline_option
@ 2012-11-30 16:14 Bernhard Voelker
  2012-12-04 15:22 ` Bernhard Voelker
  0 siblings, 1 reply; 3+ messages in thread
From: Bernhard Voelker @ 2012-11-30 16:14 UTC (permalink / raw)
  To: util-linux@vger.kernel.org

>From 4ddf21607847570e1da3b692276f2a8242bd5af6 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <mail@bernhard-voelker.de>
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@bernhard-voelker.de>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-12-10 12:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-30 16:14 [PATCH] libmount: avoid endless loop in, mnt_get_kernel_cmdline_option Bernhard Voelker
2012-12-04 15:22 ` Bernhard Voelker
2012-12-10 12:44   ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox