Skip to contentSkip to conversation

erofs-utils: lib: fix maximum huffman length for kite-deflate

PATCH In review Gao Xiang 2 participants 2 messages Apr 10, 2025 – Apr 11, 2025 Library code

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs-utils: lib: fix maximum huffman length for kite-deflate

It should be kTableDirectLevels - 1 (15) instead of 16; otherwise, it will be incorrectly identified as kBitLensRepNumber_3_6.

---
 lib/kite_deflate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/kite_deflate.c +2 -2
index 592c4d1..7e92c7c 100644
@@ -52,6 +52,8 @@ unsigned long erofs_memcmp2(const u8 *s1, const u8 *s2,
 #define kBitLens0Number_3_10    (kBitLensRepNumber_3_6 + 1)
 #define kBitLens0Number_11_138  (kBitLens0Number_3_10 + 1)
 
+#define kMaxLen                 (kTableDirectLevels - 1)
+
 static u32 kstaticHuff_mainCodes[kFixedLenTableSize];
 static const u8 kstaticHuff_litLenLevels[kFixedLenTableSize] = {
 	[0   ... 143] = 8, [144 ... 255] = 9,
@@ -180,8 +182,6 @@ static void flushbits(struct kite_deflate *s)
 	s->inflightbits = 0;
 }
 
-#define kMaxLen 16
-
 static void deflate_genhuffcodes(const u8 *lens, u32 *p, unsigned int nr_codes,
 				 const u32 *bl_count)
 {
Signature · 1 line
2.43.5