Skip to contentSkip to conversation

Don't dereference NULL upon slashless module dependency line.

PATCH In review Jim Meyering 3 participants 3 messages Feb 23, 2009 – Mar 9, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Don't dereference NULL upon slashless module dependency line.

* probe.c (check_for_modules): Skip current line if it has no slash.

---
I found this by inspection while looking for the cause of a recent rawhide/nash segfault.

 lib/blkid/probe.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
lib/blkid/probe.c +3 -2
index 76763ae..f5fff6b 100644
@@ -225,8 +225,9 @@ static int check_for_modules(const char *fs_name)
 			*cp = 0;
 		else
 			continue;
-		if ((cp = strrchr(buf, '/')) != NULL)
-			cp++;
+		if ((cp = strrchr(buf, '/')) == NULL)
+			continue;
+		cp++;
 		i = strlen(cp);
 		if (i > 3) {
 			t = cp + i - 3;

--
1.6.2.rc1.256.g58a87

#1 lore raw
Quoted 17 lines · Jim Meyering

* probe.c (check_for_modules): Skip current line if it has no slash.

---
I found this by inspection while looking for the cause of a recent rawhide/nash segfault.

 lib/blkid/probe.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
lib/blkid/probe.c +0 -0
index 76763ae..f5fff6b 100644
@@ -225,8 +225,9 @@ static int check_for_modules(const char *fs_name)
 			*cp = 0;
 		else

lib/blkid/probe.c static int check_for_modules(const char *fs_name)

Quoted 10 lines
lib/blkid/probe.c +3 -3
 			continue;
-		if ((cp = strrchr(buf, '/')) != NULL)
-			cp++;
+		if ((cp = strrchr(buf, '/')) == NULL)
+			continue;
+		cp++;
 		i = strlen(cp);
 		if (i > 3) {
 			t = cp + i - 3;
--

oops, I missed that Jim sent this (or just didn't remember w/ my goldfish brain)

OTOH the other patch I sent is probably a bit better, it gets both pieces of duplicated(!) code, and doeesn't skip these lines in modules.dep, it just skips the pre-"/"-stripping ...

-Eric

#2 lore raw
In reply to Jim Meyering
Quoted 2 lines · Jim Meyering

* probe.c (check_for_modules): Skip current line if it has no slash.

Thanks for pointing this out; I've used Eric's patch to fix this issue.

- Ted