diff options
author | marius <marius@FreeBSD.org> | 2005-10-25 12:49:56 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2005-10-25 12:49:56 +0000 |
commit | e5242bfb17c17c2a2d04b54f18885f14888d590e (patch) | |
tree | 2a817b11235fc00d9faf442ad08fdd4a7f2234c7 /sys/boot/ofw | |
parent | d6cdac5f7a822ac91d262ee4f9552a385500c3aa (diff) | |
download | FreeBSD-src-e5242bfb17c17c2a2d04b54f18885f14888d590e.zip FreeBSD-src-e5242bfb17c17c2a2d04b54f18885f14888d590e.tar.gz |
In ofw_parsedev() check the return value of malloc() and protect
against a NULL pointer dereference when ofw_parsedev() is called
with a NULL path argument.
Tested on: powerpc (grehan), sparc64
Diffstat (limited to 'sys/boot/ofw')
-rw-r--r-- | sys/boot/ofw/libofw/devicename.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/boot/ofw/libofw/devicename.c b/sys/boot/ofw/libofw/devicename.c index a2c4897..3cae23c 100644 --- a/sys/boot/ofw/libofw/devicename.c +++ b/sys/boot/ofw/libofw/devicename.c @@ -99,9 +99,13 @@ ofw_parsedev(struct ofw_devdesc **dev, const char *devspec, const char **path) return(ENOENT); found: - if (*s != '\0') + if (path != NULL && *s != '\0') *path = s; idev = malloc(sizeof(struct ofw_devdesc)); + if (idev == NULL) { + printf("ofw_parsedev: malloc failed\n"); + return ENOMEM; + } strcpy(idev->d_path, name); idev->d_dev = dv; idev->d_type = dv->dv_type; |