Skip to content

qpl/sources/middle-layer/compression/deflate/containers /huffman_table.cpp: Potential Integer Overflow #49

Description

@stasos24

Case 1

Since

fixed_codes[i].length is unt8_t

and

ll_histogram[i] is unt32_t

There is could be possible integer overflow at:

fixed_compressed_len += fixed_ll_codes[i].length * ll_histogram[i];

Possible fix:

static_cast<uint64_t>(ll_codes[i].length) * ll_histogram[i];

Case 2

Since

buffer_used(bit_buffer) + bit_buffer->m_bit_count - are unit32_t

at

compressed_len += 8 * buffer_used(bit_buffer) + bit_buffer->m_bit_count;

it would be better to cast one of them to uint64_t because compressed_len is uint64_t

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions