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.
front
cinap_lenrek 2017-12-09 18:20:29 +01:00
parent 303fb49686
commit a7ac020664
1 changed files with 5 additions and 0 deletions

View File

@ -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);
}