summaryrefslogtreecommitdiffstats
path: root/sys/boot/ofw
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2005-10-25 12:49:56 +0000
committermarius <marius@FreeBSD.org>2005-10-25 12:49:56 +0000
commite5242bfb17c17c2a2d04b54f18885f14888d590e (patch)
tree2a817b11235fc00d9faf442ad08fdd4a7f2234c7 /sys/boot/ofw
parentd6cdac5f7a822ac91d262ee4f9552a385500c3aa (diff)
downloadFreeBSD-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.c6
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;
OpenPOWER on IntegriCloud