summaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
authorDenys Vlasenko2010-01-26 08:17:45 +0100
committerDenys Vlasenko2010-01-26 08:17:45 +0100
commitda879ec2e967e2f04f6269e506308dc9cc8b97ae (patch)
tree7d00268ef7a17749ae1241453260efe407e810a3 /modutils
parent1aaf1cb096e2d8d0d1c21e44e425072c122e6a7e (diff)
downloadbusybox-da879ec2e967e2f04f6269e506308dc9cc8b97ae.zip
busybox-da879ec2e967e2f04f6269e506308dc9cc8b97ae.tar.gz
modprobe: protect against possible SEGV
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'modutils')
-rw-r--r--modutils/modprobe.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index 2860ae0..f339fbd 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -80,12 +80,14 @@ 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) {
+ 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;
}