[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 <[email protected]>
>From 68e71eba7b3384543c46f43e873421ee0b8722a0 Mon Sep 17 00:00:00 2001 From: Matthew White <[email protected]> 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); -- 2.7.3
pgpa0NRb3LofY.pgp
Description: PGP signature
