Skip to contentSkip to conversation

erofs-utils: lib: fix potential overflow issue

PATCH New Hongzhen Luo 1 participant 1 message Aug 13, 2024 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 erofs-utils: lib: fix potential overflow issue

Coverity-id: 502353

Change 8U to 8ULL to avoid arithmetic multiplication overflow.

---
 lib/kite_deflate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/kite_deflate.c +1 -1
index 8581834..4b1068b 100644
@@ -892,7 +892,7 @@ static bool deflate_count_code(struct kite_deflate *s, bool literal,
 {
 	struct kite_deflate_table *t = s->tab;
 	unsigned int lenbase = (literal ? 0 : kSymbolMatch);
-	u64 rem = (s->outlen - s->pos_out) * 8 - s->bitpos;
+	u64 rem = (s->outlen - s->pos_out) * 8ULL - s->bitpos;
 	bool recalc = false;
 	unsigned int bits;
 
Signature · 1 line
2.43.5