mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-24 22:00:18 +00:00
Prevent possible max shift value (#5391)
Protect against shifts that might be bigger than 31
This commit is contained in:
parent
4831b504bc
commit
ca96796268
@ -1790,6 +1790,7 @@ static Register parseReg(RAsm *a, const char *str, size_t *pos, ut32 *type) {
|
||||
(reg = getnum (a, str + *pos)) > 7) {
|
||||
if ((int)reg > 15) {
|
||||
eprintf ("Too large register index!\n");
|
||||
return X86R_UNDEFINED;
|
||||
} else {
|
||||
reg -= 8;
|
||||
}
|
||||
@ -1801,6 +1802,12 @@ static Register parseReg(RAsm *a, const char *str, size_t *pos, ut32 *type) {
|
||||
if (getToken (str, pos, &nextpos) == TT_SPECIAL && str[*pos] == ')') {
|
||||
*pos = nextpos;
|
||||
}
|
||||
// Safety to prevent a shift bigger than 31. Reg
|
||||
// should never be > 8 anyway
|
||||
if (reg > 7) {
|
||||
eprintf ("Too large register index!\n");
|
||||
return X86R_UNDEFINED;
|
||||
}
|
||||
*type |= (OT_REG(reg) & ~OT_REGTYPE);
|
||||
return reg;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user