intel / intel/qpl

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

Open
#49 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
110
Forks
28
PR merge metrics
No merged PRs in 30d

Description

### 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:

https://github.com/intel/qpl/blob/d08be0031eb5741ee1372651ba52a671308bb296/sources/middle-layer/compression/deflate/containers/huffman_table.cpp#L134

Possible fix:
```
static_cast(ll_codes[i].length) * ll_histogram[i];
```

### Case 2

Since
```
buffer_used(bit_buffer) + bit_buffer->m_bit_count - are unit32_t
```
at
https://github.com/intel/qpl/blob/d08be0031eb5741ee1372651ba52a671308bb296/sources/middle-layer/compression/deflate/containers/huffman_table.cpp#L164

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.