]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fixed arithmetic overflow when emitting deflate header bits.
authorNathan Moinvaziri <nathan@nathanm.com>
Mon, 1 Jun 2020 04:46:03 +0000 (21:46 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Mon, 8 Jun 2020 19:13:01 +0000 (21:13 +0200)
    Arithmetic overflow: 32-bit value is shifted, then cast to 64-bit value.
      Results might not be an expected value.

trees_emit.h

index efc4a71b0f83db7ca1e7ed35a9e1445106b4f340..30613f70816f1ef839507a39203b13af059393d6 100644 (file)
@@ -196,7 +196,8 @@ static inline void zng_tr_emit_dist(deflate_state *s, const ct_data *ltree, cons
 static inline void zng_tr_emit_tree(deflate_state *s, int type, const int last) {
     uint32_t bi_valid = s->bi_valid;
     uint64_t bi_buf = s->bi_buf;
-    send_bits(s, (type << 1) + last, 3, bi_buf, bi_valid);
+    uint32_t header_bits = (type << 1) + last;
+    send_bits(s, header_bits, 3, bi_buf, bi_valid);
     cmpr_bits_add(s, 3);
     s->bi_valid = bi_valid;
     s->bi_buf = bi_buf;