summaryrefslogtreecommitdiff
path: root/net-misc/wget/files/wget-1.19.2-fix-segfault-due-to-derefencing-null-ptr.patch
blob: 8a66e08c3e3bb6878e6beeb260025b0b9a845db7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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