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.
This commit is contained in:
marius 2005-11-30 13:24:53 +00:00
parent 4245a23502
commit 9eaee5a55c

View File

@ -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;