Prevent possible max shift value (#5391)

Protect against shifts that might be bigger than 31
This commit is contained in:
Sven Steinbauer 2016-07-27 12:21:36 +01:00 committed by radare
parent 4831b504bc
commit ca96796268

View File

@ -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;
}