From 9eaee5a55c91dba44a2623fc673715f6f739852e Mon Sep 17 00:00:00 2001 From: marius Date: Wed, 30 Nov 2005 13:24:53 +0000 Subject: [PATCH] MFC: 1.16 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. --- sys/boot/ofw/libofw/devicename.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/boot/ofw/libofw/devicename.c b/sys/boot/ofw/libofw/devicename.c index a2c48975417a..3cae23ce2024 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;