wget/wget-1.19.2-fix-segfault-in-http-c.patch
Tomas Hozza 0646b68da4 Fix segfault when calling strchr in http.c (#1511562)
Signed-off-by: Tomas Hozza <thozza@redhat.com>
2017-12-08 17:09:00 +01:00

47 lines
1.5 KiB
Diff

diff --git a/src/http.c b/src/http.c
index dc31823..47de828 100644
--- a/src/http.c
+++ b/src/http.c
@@ -3712,22 +3712,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