Dereferencing uninitialized pointers considered harmful. Prior to this

commit, calling i386_parsedev(..., X, ...) where X is "ad", "bge", or
any other disk or network device name without a unit number, would
result in dereferencing whatever happened to be on the stack where the
variable "cp" is stored.

Found by:	LLVM/Clang Static Checker
This commit is contained in:
cperciva 2008-08-04 07:01:42 +00:00
parent 5b18df3c73
commit cebedc3498

View File

@ -150,6 +150,8 @@ i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path)
cp++;
}
}
} else {
cp = np;
}
if (*cp && (*cp != ':')) {
err = EINVAL;
@ -173,6 +175,8 @@ i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path)
err = EUNIT;
goto fail;
}
} else {
cp = np;
}
if (*cp && (*cp != ':')) {
err = EINVAL;