[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-wget] [PATCH 24/25] Bugfix: Set NULL variable due to --content-
From: |
Giuseppe Scrivano |
Subject: |
Re: [Bug-wget] [PATCH 24/25] Bugfix: Set NULL variable due to --content-disposition to Metalink origin |
Date: |
Sun, 11 Sep 2016 23:44:01 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) |
> [Coverity Scan is ok, make syntax-check is ok, make check-valgrind is ok,
> contrib/check-hard is ok]
>
> This solves a segmentation fault when local_file is not properly set, i.e.
> due to the use of the option --content-disposition.
>
> The segmentation fault was generated trying to dereference a NULL local_file.
>
> Regards,
> Matthew
>
> --
> Matthew White <address@hidden>
>
> From 68e71eba7b3384543c46f43e873421ee0b8722a0 Mon Sep 17 00:00:00 2001
> From: Matthew White <address@hidden>
> Date: Tue, 30 Aug 2016 12:09:38 +0200
> Subject: [PATCH 24/25] Bugfix: Set NULL variable due to --content-disposition
> to Metalink origin
>
> * src/http.c (http_loop): Prevent SIGSEGV when hstat.local_file is
> NULL, opt.content_disposition has a role in leaving the value unset
> * src/http.c (gethttp): If hs->local_file is NULL (aka http_loop()'s
> hstat.local_file), set it to the value of hs->metalink->origin
> ---
> src/http.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/src/http.c b/src/http.c
> index 753f960..e7d18dd 100644
> --- a/src/http.c
> +++ b/src/http.c
> @@ -3380,6 +3380,9 @@ gethttp (const struct url *u, struct url *original_url,
> struct http_stat *hs,
> if (metalink)
> {
> hs->metalink = metalink_from_http (resp, hs, u);
> + /* Bugfix: hs->local_file is NULL (opt.content_disposition). */
> + if (!hs->local_file && hs->metalink && hs->metalink->origin)
> + hs->local_file = xstrdup (hs->metalink->origin);
> xfree (hs->message);
> retval = RETR_WITH_METALINK;
> CLOSE_FINISH (sock);
> @@ -4499,7 +4502,10 @@ exit:
> if ((ret == RETROK || opt.content_on_error) && local_file)
> {
> xfree (*local_file);
> - *local_file = xstrdup (hstat.local_file);
> + /* Bugfix: Prevent SIGSEGV when hstat.local_file was left NULL
> + (i.e. due to opt.content_disposition). */
> + if (hstat.local_file)
> + *local_file = xstrdup (hstat.local_file);
> }
> free_hstat (&hstat);
ACK
Giuseppe