Skip to content

fix 32-bit overflow in LZW byte-list size calculation#119

Open
jmestwa-coder wants to merge 1 commit into
dloebl:mainfrom
jmestwa-coder:lzw-bytelist-size-overflow
Open

fix 32-bit overflow in LZW byte-list size calculation#119
jmestwa-coder wants to merge 1 commit into
dloebl:mainfrom
jmestwa-coder:lzw-bytelist-size-overflow

Conversation

@jmestwa-coder

Copy link
Copy Markdown

clang -fsanitize=unsigned-integer-overflow on the byte-list size calc:

runtime error: unsigned integer overflow:
  12 * 400000000 cannot be represented in type 'uint32_t'

MAX_CODE_LEN * lzwPos is an intuint32_t product that wraps in 32-bit before the /8ull widening, so for large frames (lzwPos > ~358M, reachable with in-spec widthheight) byteList/byteListBlock are sized far too small and create_byte_list overruns the heap. Widen the multiply to 64-bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant