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:
parent
5b18df3c73
commit
cebedc3498
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user