summaryrefslogtreecommitdiff
path: root/sys/src/libflate/deflate.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2017-12-09 18:20:29 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2017-12-09 18:20:29 +0100
commita7ac020664f1de870b09807086565030246ad6fb (patch)
treea2c6cc659514ea39f87c4937fae8f2035244f947 /sys/src/libflate/deflate.c
parent303fb4968634b7fd16815d4c16777dba0bf97f13 (diff)
libflate: force non-empty huffman table in mkzprecode() for deflate
busybox gunzip fails on empty (offset) huffman tables, so force one entry. gzip states in a comment: The pkzip format requires that at least one distance code exists, and that at least one bit should be sent even if there is only one possible code.
Diffstat (limited to 'sys/src/libflate/deflate.c')
-rw-r--r--sys/src/libflate/deflate.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/sys/src/libflate/deflate.c b/sys/src/libflate/deflate.c
index 1eb7e866c..11c24cd6d 100644
--- a/sys/src/libflate/deflate.c
+++ b/sys/src/libflate/deflate.c
@@ -1063,6 +1063,11 @@ mkgzprecode(Huff *tab, ulong *count, int n, int maxbits)
}
if(bitcount[0] != 0)
return 0;
+ if(nbits == 0){
+ bitcount[1] = 1;
+ nbits = 1;
+ tab[0].bits = 1;
+ }
return hufftabinit(tab, n, bitcount, nbits);
}