Browse Source

inflate: fix missing byte read for compression type in gzip deflater

K. Lange 8 months ago
parent
commit
1c0e741c99
1 changed files with 5 additions and 2 deletions
  1. 5 2
      lib/inflate.c

+ 5 - 2
lib/inflate.c

@@ -429,6 +429,9 @@ int gzip_decompress(struct inflate_context * ctx) {
 	if (ctx->get_input(ctx) != 0x1F) return 1;
 	if (ctx->get_input(ctx) != 0x8B) return 1;
 
+	unsigned int cm = ctx->get_input(ctx);
+	if (cm != 8) return 1;
+
 	unsigned int flags = ctx->get_input(ctx);
 
 	/* Read mtime */
@@ -465,7 +468,7 @@ int gzip_decompress(struct inflate_context * ctx) {
 	}
 	(void)crc16;
 
-	deflate_decompress(ctx);
+	int status = deflate_decompress(ctx);
 
 	/* Read CRC and decompressed size from end of input */
 	unsigned int crc32 = read_32le(ctx);
@@ -474,5 +477,5 @@ int gzip_decompress(struct inflate_context * ctx) {
 	(void)crc32;
 	(void)dsize;
 
-	return 0;
+	return status;
 }