Prevent undefined behavior in decode_length
This commit is contained in:
parent
d8b13bd417
commit
b87066da92
1
AUTHORS
1
AUTHORS
|
@ -32,6 +32,7 @@ Etienne Cimon
|
||||||
Fabian Möller
|
Fabian Möller
|
||||||
Fabian Wiesel
|
Fabian Wiesel
|
||||||
Gabi Davar
|
Gabi Davar
|
||||||
|
Google Inc.
|
||||||
Jacob Champion
|
Jacob Champion
|
||||||
Jan-E
|
Jan-E
|
||||||
Janusz Dziemidowicz
|
Janusz Dziemidowicz
|
||||||
|
|
|
@ -864,6 +864,11 @@ static ssize_t decode_length(uint32_t *res, size_t *shift_ptr, int *fin,
|
||||||
for (; in != last; ++in, shift += 7) {
|
for (; in != last; ++in, shift += 7) {
|
||||||
uint32_t add = *in & 0x7f;
|
uint32_t add = *in & 0x7f;
|
||||||
|
|
||||||
|
if (shift >= 32) {
|
||||||
|
DEBUGF("inflate: shift exponent overflow\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if ((UINT32_MAX >> shift) < add) {
|
if ((UINT32_MAX >> shift) < add) {
|
||||||
DEBUGF("inflate: integer overflow on shift\n");
|
DEBUGF("inflate: integer overflow on shift\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue