[vlc-commits] inflate: add support for gzip (refs #16412)

Rémi Denis-Courmont git at videolan.org
Mon Feb 1 22:08:24 CET 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Feb  1 22:58:56 2016 +0200| [2e4b3ffd72fbff49f1b0ee8be5b64fbae2e3da30] | committer: Rémi Denis-Courmont

inflate: add support for gzip (refs #16412)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2e4b3ffd72fbff49f1b0ee8be5b64fbae2e3da30
---

 modules/stream_filter/inflate.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/modules/stream_filter/inflate.c b/modules/stream_filter/inflate.c
index c915b60..543d563 100644
--- a/modules/stream_filter/inflate.c
+++ b/modules/stream_filter/inflate.c
@@ -151,10 +151,18 @@ static int Open(vlc_object_t *obj)
 {
     stream_t *stream = (stream_t *)obj;
     const uint8_t *peek;
+    int bits;
 
     /* See IETF RFC6713 */
-    if (stream_Peek(stream->p_source, &peek, 2) < 2
-     || (peek[0] & 0xF) != 8 || (peek[0] >> 4) > 7 || (U16_AT(peek) % 31) != 0)
+    if (stream_Peek(stream->p_source, &peek, 2) < 2)
+        return VLC_EGENERIC;
+
+    if ((peek[0] & 0xF) == 8 && (peek[0] >> 4) < 8 && (U16_AT(peek) % 31) == 0)
+        bits = 15; /* zlib */
+    else
+    if (!memcmp(peek, "\x1F\x08B", 2))
+        bits = 15 + 32; /* gzip */
+    else
         return VLC_EGENERIC;
 
     stream_sys_t *sys = malloc(sizeof (*sys));
@@ -168,7 +176,7 @@ static int Open(vlc_object_t *obj)
     sys->zstream.opaque = Z_NULL;
     sys->eof = false;
 
-    int ret = inflateInit(&sys->zstream);
+    int ret = inflateInit2(&sys->zstream, bits);
     if (ret != Z_OK)
     {
         free(sys);



More information about the vlc-commits mailing list