[PATCH] modutils/modprobe.c: Avoid possible NULL pointer dereference
walter harms
wharms at bfs.de
Wed Jan 27 08:13:33 UTC 2010
Ozan Çağlayan schrieb:
> 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;
> }
sorry about beeing late, perhaps you can save a few bytes by using asprintf() ?
} else {
asprintf(opts,"%s %s",opts,append);
}
More information about the busybox
mailing list