[PATCH] modutils/modprobe.c: Avoid possible NULL pointer dereference
Ozan Çağlayan
ozan at pardus.org.tr
Tue Jan 26 08:17:22 UTC 2010
Check against append to avoid possible NULL pointer dereferences.
---
modutils/modprobe.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index 2860ae0..e2f59c2 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -79,13 +79,15 @@ static int read_config(const char *path);
static char *gather_options_str(char *opts, const char *append)
{
- /* Speed-optimized. We call gather_options_str many times. */
- if (opts == NULL) {
- opts = xstrdup(append);
- } else {
- int optlen = strlen(opts);
- opts = xrealloc(opts, optlen + strlen(append) + 2);
- sprintf(opts + optlen, " %s", append);
+ if (append) {
+ /* Speed-optimized. We call gather_options_str many times. */
+ if (opts == NULL) {
+ opts = xstrdup(append);
+ } else {
+ int optlen = strlen(opts);
+ opts = xrealloc(opts, optlen + strlen(append) + 2);
+ sprintf(opts + optlen, " %s", append);
+ }
}
return opts;
}
--
1.6.5.6
More information about the busybox
mailing list