mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-24 23:07:17 +00:00
Merge pull request #8496 from s-hadinger/unishox_fix
Fix crash in unishox decompress #8486
This commit is contained in:
commit
3df4161043
@ -433,8 +433,8 @@ int32_t Unishox::getNumFromBits(uint32_t count) {
|
|||||||
// Code size optimized, recalculate adder[] like in encodeCount
|
// Code size optimized, recalculate adder[] like in encodeCount
|
||||||
uint32_t Unishox::readCount(void) {
|
uint32_t Unishox::readCount(void) {
|
||||||
int32_t idx = getCodeIdx(us_hcode);
|
int32_t idx = getCodeIdx(us_hcode);
|
||||||
|
if ((1 == idx) || (idx >= sizeof(bit_len)) || (idx < 0)) return 0; // unsupported or end of stream
|
||||||
if (idx >= 1) idx--; // we skip v = 1 (code '0') since we no more accept 2 bits encoding
|
if (idx >= 1) idx--; // we skip v = 1 (code '0') since we no more accept 2 bits encoding
|
||||||
if ((idx >= sizeof(bit_len)) || (idx < 0)) return 0; // unsupported or end of stream
|
|
||||||
|
|
||||||
int base;
|
int base;
|
||||||
int till = 0;
|
int till = 0;
|
||||||
@ -470,7 +470,7 @@ int32_t Unishox::unishox_decompress(const char *p_in, size_t p_len, char *p_out,
|
|||||||
|
|
||||||
len <<= 3; // *8, len in bits
|
len <<= 3; // *8, len in bits
|
||||||
out[ol] = 0;
|
out[ol] = 0;
|
||||||
while (bit_no < len) {
|
while ((byte_no << 3) + bit_no - 8 < len) {
|
||||||
int32_t h, v;
|
int32_t h, v;
|
||||||
char c = 0;
|
char c = 0;
|
||||||
byte is_upper = is_all_upper;
|
byte is_upper = is_all_upper;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user