modprobe: protect against possible SEGV

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2010-01-26 08:17:45 +01:00
parent 1aaf1cb096
commit da879ec2e9

View File

@ -80,12 +80,14 @@ static int read_config(const char *path);
static char *gather_options_str(char *opts, const char *append) static char *gather_options_str(char *opts, const char *append)
{ {
/* Speed-optimized. We call gather_options_str many times. */ /* Speed-optimized. We call gather_options_str many times. */
if (opts == NULL) { if (append) {
opts = xstrdup(append); if (opts == NULL) {
} else { opts = xstrdup(append);
int optlen = strlen(opts); } else {
opts = xrealloc(opts, optlen + strlen(append) + 2); int optlen = strlen(opts);
sprintf(opts + optlen, " %s", append); opts = xrealloc(opts, optlen + strlen(append) + 2);
sprintf(opts + optlen, " %s", append);
}
} }
return opts; return opts;
} }