[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 11/153: content_encoding: accept up to 4 unknown tr
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 11/153: content_encoding: accept up to 4 unknown trailer bytes after raw deflate data |
Date: |
Tue, 11 Sep 2018 12:51:22 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit f8be737d8f5276a6ab4c9560d896fb5585d2933e
Author: Patrick Monnerat <address@hidden>
AuthorDate: Thu Jul 12 22:46:15 2018 +0200
content_encoding: accept up to 4 unknown trailer bytes after raw deflate
data
Some servers issue raw deflate data that may be followed by an undocumented
trailer. This commit makes curl tolerate such a trailer of up to 4 bytes
before considering the data is in error.
Reported-by: clbr on github
Fixes #2719
---
lib/content_encoding.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/lib/content_encoding.c b/lib/content_encoding.c
index d69ad5c5a..6d4753788 100644
--- a/lib/content_encoding.c
+++ b/lib/content_encoding.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <address@hidden>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <address@hidden>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -71,13 +71,13 @@
#define RESERVED 0xE0 /* bits 5..7: reserved */
typedef enum {
- ZLIB_UNINIT, /* uninitialized */
- ZLIB_INIT, /* initialized */
- ZLIB_INFLATING, /* Inflating started. */
- ZLIB_GZIP_HEADER, /* reading gzip header */
- ZLIB_GZIP_TRAILER, /* reading gzip trailer */
- ZLIB_GZIP_INFLATING, /* inflating gzip stream */
- ZLIB_INIT_GZIP /* initialized in transparent gzip mode */
+ ZLIB_UNINIT, /* uninitialized */
+ ZLIB_INIT, /* initialized */
+ ZLIB_INFLATING, /* inflating started. */
+ ZLIB_EXTERNAL_TRAILER, /* reading external trailer */
+ ZLIB_GZIP_HEADER, /* reading gzip header */
+ ZLIB_GZIP_INFLATING, /* inflating gzip stream */
+ ZLIB_INIT_GZIP /* initialized in transparent gzip mode */
} zlibInitState;
/* Writer parameters. */
@@ -150,8 +150,8 @@ static CURLcode process_trailer(struct connectdata *conn,
zlib_params *zp)
if(result || !zp->trailerlen)
result = exit_zlib(conn, z, &zp->zlib_init, result);
else {
- /* Only occurs for gzip with zlib < 1.2.0.4. */
- zp->zlib_init = ZLIB_GZIP_TRAILER;
+ /* Only occurs for gzip with zlib < 1.2.0.4 or raw deflate. */
+ zp->zlib_init = ZLIB_EXTERNAL_TRAILER;
}
return result;
}
@@ -233,6 +233,7 @@ static CURLcode inflate_stream(struct connectdata *conn,
z->next_in = orig_in;
z->avail_in = nread;
zp->zlib_init = ZLIB_INFLATING;
+ zp->trailerlen = 4; /* Tolerate up to 4 unknown trailer bytes. */
done = FALSE;
break;
}
@@ -287,6 +288,9 @@ static CURLcode deflate_unencode_write(struct connectdata
*conn,
z->next_in = (Bytef *) buf;
z->avail_in = (uInt) nbytes;
+ if(zp->zlib_init == ZLIB_EXTERNAL_TRAILER)
+ return process_trailer(conn, zp);
+
/* Now uncompress the data */
return inflate_stream(conn, writer, ZLIB_INFLATING);
}
@@ -532,7 +536,7 @@ static CURLcode gzip_unencode_write(struct connectdata
*conn,
}
break;
- case ZLIB_GZIP_TRAILER:
+ case ZLIB_EXTERNAL_TRAILER:
z->next_in = (Bytef *) buf;
z->avail_in = (uInt) nbytes;
return process_trailer(conn, zp);
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 20/153: test214: disable MSYS2's POSIX path conversion for URL, (continued)
- [GNUnet-SVN] [gnurl] 20/153: test214: disable MSYS2's POSIX path conversion for URL, gnunet, 2018/09/11
- [GNUnet-SVN] [gnurl] 12/153: test1422: add required file feature, gnunet, 2018/09/11
- [GNUnet-SVN] [gnurl] 10/153: smb: fix memory-leak in URL parse error path, gnunet, 2018/09/11
- [GNUnet-SVN] [gnurl] 32/153: docs/examples: add hiperfifo example using linux epoll/timerfd, gnunet, 2018/09/11
- [GNUnet-SVN] [gnurl] 30/153: docs/CURLOPT_URL: fix indentation, gnunet, 2018/09/11
- [GNUnet-SVN] [gnurl] 31/153: docs/INSTALL.md: minor formatting fixes, gnunet, 2018/09/11
- [GNUnet-SVN] [gnurl] 18/153: smb_getsock: always wait for write socket too, gnunet, 2018/09/11
- [GNUnet-SVN] [gnurl] 17/153: test1143: disable MSYS2's POSIX path conversion, gnunet, 2018/09/11
- [GNUnet-SVN] [gnurl] 21/153: tests: fixes for Windows line endlings, gnunet, 2018/09/11
- [GNUnet-SVN] [gnurl] 22/153: vtls: set conn->data when closing TLS, gnunet, 2018/09/11
- [GNUnet-SVN] [gnurl] 11/153: content_encoding: accept up to 4 unknown trailer bytes after raw deflate data,
gnunet <=
- [GNUnet-SVN] [gnurl] 07/153: multi: always do the COMPLETED procedure/state, gnunet, 2018/09/11
- [GNUnet-SVN] [gnurl] 09/153: schannel: enable CALG_TLS1PRF for w32api >= 5.1, gnunet, 2018/09/11
- [GNUnet-SVN] [gnurl] 15/153: CMake: Update scripts to use consistent style, gnunet, 2018/09/11
- [GNUnet-SVN] [gnurl] 03/153: openssl: assume engine support in 1.0.0 or later, gnunet, 2018/09/11
- [GNUnet-SVN] [gnurl] 06/153: Curl_getoff_all_pipelines: improved for multiplexed, gnunet, 2018/09/11