| From 973c26ed7d51052a7b6e120ed1b84e47266667e1 Mon Sep 17 00:00:00 2001 |
| From: Darshit Shah <darnir@gnu.org> |
| Date: Mon, 6 Nov 2017 10:09:03 +0100 |
| Subject: Fix Segfault due to derefencing null ptr |
| MIME-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| * src/http.c(gethttp): When Encoding is gzip, ensure that the |
| Content-Type Header was actually seen. Without this, the "type" variable |
| is null causing a Segfault. |
| |
| Reported-By: Noël Köthe <noel@debian.org> |
| --- |
| src/http.c | 30 +++++++++++++++++++----------- |
| 1 file changed, 19 insertions(+), 11 deletions(-) |
| |
| diff --git a/src/http.c b/src/http.c |
| index 9954848..2a5454f 100644 |
| --- a/src/http.c |
| +++ b/src/http.c |
| @@ -3714,22 +3714,30 @@ gethttp (const struct url *u, struct url *original_url, struct http_stat *hs, |
| && opt.compression != compression_none) |
| { |
| /* Make sure the Content-Type is not gzip before decompressing */ |
| - const char * p = strchr (type, '/'); |
| - if (p == NULL) |
| - { |
| - hs->remote_encoding = ENC_GZIP; |
| - hs->local_encoding = ENC_NONE; |
| - } |
| - else |
| + if (type) |
| { |
| - p++; |
| - if (c_tolower(p[0]) == 'x' && p[1] == '-') |
| - p += 2; |
| - if (0 != c_strcasecmp (p, "gzip")) |
| + const char * p = strchr (type, '/'); |
| + if (p == NULL) |
| { |
| hs->remote_encoding = ENC_GZIP; |
| hs->local_encoding = ENC_NONE; |
| } |
| + else |
| + { |
| + p++; |
| + if (c_tolower(p[0]) == 'x' && p[1] == '-') |
| + p += 2; |
| + if (0 != c_strcasecmp (p, "gzip")) |
| + { |
| + hs->remote_encoding = ENC_GZIP; |
| + hs->local_encoding = ENC_NONE; |
| + } |
| + } |
| + } |
| + else |
| + { |
| + hs->remote_encoding = ENC_GZIP; |
| + hs->local_encoding = ENC_NONE; |
| } |
| } |
| #endif |
| -- |
| cgit v1.0-41-gc330 |
| |