]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-compression: Fix length checks for zlib header
authorPhilippe Antoine <contact@catenacyber.fr>
Tue, 31 Mar 2020 07:57:38 +0000 (09:57 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 8 Apr 2020 08:01:46 +0000 (08:01 +0000)
src/lib-compression/istream-zlib.c

index 3e514cab84267090f7a09e59414b0dbbf333bcf8..c04df039d8f68bbd7b95ac43b7afbe1ad55d47fb 100644 (file)
@@ -100,12 +100,12 @@ static int i_stream_zlib_read_header(struct istream_private *stream)
                return -1;
        }
        if ((data[3] & GZ_FLAG_FEXTRA) != 0) {
-               if (pos + 2 < size)
+               if (pos + 2 > size)
                        return 0;
 
                fextra_size = le16_to_cpu_unaligned(&data[pos]);
                pos += 2;
-               if (pos + fextra_size < size)
+               if (pos + fextra_size > size)
                        return 0;
                pos += fextra_size;
        }
@@ -122,7 +122,7 @@ static int i_stream_zlib_read_header(struct istream_private *stream)
                } while (data[pos++] != '\0');
        }
        if ((data[3] & GZ_FLAG_FHCRC) != 0) {
-               if (pos + 2 < size)
+               if (pos + 2 > size)
                        return 0;
                pos += 2;
        }