diff mbox

Don't dereference NULL upon slashless module dependency line.

Message ID 87fxi5dt0g.fsf@meyering.net
State Superseded, archived
Headers show

Commit Message

Jim Meyering Feb. 23, 2009, 4:20 p.m. UTC
* probe.c (check_for_modules): Skip current line if it has no slash.

Signed-off-by: Jim Meyering <meyering@redhat.com>
---
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(-)

--
1.6.2.rc1.256.g58a87
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Eric Sandeen Feb. 26, 2009, 10:18 p.m. UTC | #1
Jim Meyering wrote:
> * probe.c (check_for_modules): Skip current line if it has no slash.
> 
> Signed-off-by: Jim Meyering <meyering@redhat.com>
> ---
> 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(-)
> 
> diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c
> index 76763ae..f5fff6b 100644
> --- a/lib/blkid/probe.c
> +++ b/lib/blkid/probe.c
> @@ -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;
> --

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
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Theodore Ts'o March 9, 2009, 12:41 a.m. UTC | #2
On Mon, Feb 23, 2009 at 05:20:47PM +0100, Jim Meyering wrote:
> 
> * 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
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c
index 76763ae..f5fff6b 100644
--- a/lib/blkid/probe.c
+++ b/lib/blkid/probe.c
@@ -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;