[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] modutils/modprobe.c: Avoid possible NULL pointer
From: walter harms <wharms () bfs ! de>
Date: 2010-01-27 8:13:33
Message-ID: 4B5FF5AD.4000704 () bfs ! de
[Download RAW message or body]
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);
}
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic