* [PATCH] e2fsprogs: fix potential null ptr defef in check_for_modules()
@ 2009-02-24 21:13 Eric Sandeen
2009-02-26 22:20 ` [PATCH] e2fsprogs: fix potential null ptr deref " Eric Sandeen
2009-03-06 7:38 ` [PATCH] e2fsprogs: fix potential null ptr defef " Theodore Tso
0 siblings, 2 replies; 3+ messages in thread
From: Eric Sandeen @ 2009-02-24 21:13 UTC (permalink / raw)
To: ext4 development
The coverity scanner found this one.
If a line in modules.dep has a ":" but no "/" then:
if ((cp = strchr(buf, ':')) != NULL)
*cp = 0;
else
continue;
if ((cp = strrchr(buf, '/')) != NULL)
cp++;
/* XXX else cp is still null */
i = strlen(cp);
... we will deref a null pointer (cp). This can be
demonstrated by putting a line like:
foo.ko:
into modules.dep. The below change just says that if no "/" is
found, treat the whole string as the module name.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
Index: e2fsprogs/e2fsck/util.c
===================================================================
--- e2fsprogs.orig/e2fsck/util.c
+++ e2fsprogs/e2fsck/util.c
@@ -663,6 +663,8 @@ int check_for_modules(const char *fs_nam
continue;
if ((cp = strrchr(buf, '/')) != NULL)
cp++;
+ else
+ cp = buf;
i = strlen(cp);
if (i > 3) {
t = cp + i - 3;
Index: e2fsprogs/lib/blkid/probe.c
===================================================================
--- e2fsprogs.orig/lib/blkid/probe.c
+++ e2fsprogs/lib/blkid/probe.c
@@ -227,6 +227,8 @@ static int check_for_modules(const char
continue;
if ((cp = strrchr(buf, '/')) != NULL)
cp++;
+ else
+ cp = buf;
i = strlen(cp);
if (i > 3) {
t = cp + i - 3;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] e2fsprogs: fix potential null ptr deref in check_for_modules()
2009-02-24 21:13 [PATCH] e2fsprogs: fix potential null ptr defef in check_for_modules() Eric Sandeen
@ 2009-02-26 22:20 ` Eric Sandeen
2009-03-06 7:38 ` [PATCH] e2fsprogs: fix potential null ptr defef " Theodore Tso
1 sibling, 0 replies; 3+ messages in thread
From: Eric Sandeen @ 2009-02-26 22:20 UTC (permalink / raw)
To: ext4 development
Eric Sandeen wrote:
> The coverity scanner found this one.
>
> If a line in modules.dep has a ":" but no "/" then:
>
> if ((cp = strchr(buf, ':')) != NULL)
> *cp = 0;
> else
> continue;
> if ((cp = strrchr(buf, '/')) != NULL)
> cp++;
> /* XXX else cp is still null */
> i = strlen(cp);
>
> ... we will deref a null pointer (cp). This can be
> demonstrated by putting a line like:
>
> foo.ko:
>
> into modules.dep. The below change just says that if no "/" is
> found, treat the whole string as the module name.
FWIW; this resolves RH bugzilla:
[Bug 486997] rawhide's init/nash segfaults in libblkid
and also is an extension of the patch Jim sent a couple days ago.
The issue is that for fedora initrds, anyway, modules dep is something like:
crc16.ko:
ext4.ko: jbd2.ko crc16.ko
...
so it hits exactly this case.
-Eric
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>
> Index: e2fsprogs/e2fsck/util.c
> ===================================================================
> --- e2fsprogs.orig/e2fsck/util.c
> +++ e2fsprogs/e2fsck/util.c
> @@ -663,6 +663,8 @@ int check_for_modules(const char *fs_nam
> continue;
> if ((cp = strrchr(buf, '/')) != NULL)
> cp++;
> + else
> + cp = buf;
> i = strlen(cp);
> if (i > 3) {
> t = cp + i - 3;
> Index: e2fsprogs/lib/blkid/probe.c
> ===================================================================
> --- e2fsprogs.orig/lib/blkid/probe.c
> +++ e2fsprogs/lib/blkid/probe.c
> @@ -227,6 +227,8 @@ static int check_for_modules(const char
> continue;
> if ((cp = strrchr(buf, '/')) != NULL)
> cp++;
> + else
> + cp = buf;
> i = strlen(cp);
> if (i > 3) {
> t = cp + i - 3;
>
> --
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] e2fsprogs: fix potential null ptr defef in check_for_modules()
2009-02-24 21:13 [PATCH] e2fsprogs: fix potential null ptr defef in check_for_modules() Eric Sandeen
2009-02-26 22:20 ` [PATCH] e2fsprogs: fix potential null ptr deref " Eric Sandeen
@ 2009-03-06 7:38 ` Theodore Tso
1 sibling, 0 replies; 3+ messages in thread
From: Theodore Tso @ 2009-03-06 7:38 UTC (permalink / raw)
To: Eric Sandeen; +Cc: ext4 development
On Tue, Feb 24, 2009 at 03:13:39PM -0600, Eric Sandeen wrote:
> The coverity scanner found this one.
>
> If a line in modules.dep has a ":" but no "/" then:
>
> if ((cp = strchr(buf, ':')) != NULL)
> *cp = 0;
> else
> continue;
> if ((cp = strrchr(buf, '/')) != NULL)
> cp++;
> /* XXX else cp is still null */
> i = strlen(cp);
>
> ... we will deref a null pointer (cp). This can be
> demonstrated by putting a line like:
>
> foo.ko:
>
> into modules.dep. The below change just says that if no "/" is
> found, treat the whole string as the module name.
Thanks, applied to the e2fsprogs git tree.
- Ted
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-03-06 7:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-24 21:13 [PATCH] e2fsprogs: fix potential null ptr defef in check_for_modules() Eric Sandeen
2009-02-26 22:20 ` [PATCH] e2fsprogs: fix potential null ptr deref " Eric Sandeen
2009-03-06 7:38 ` [PATCH] e2fsprogs: fix potential null ptr defef " Theodore Tso
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.