ubsan: tic6x: shift left of int

* tic6x-dis.c (tic6x_extract_32): Avoid signed overflow.
This commit is contained in:
Alan Modra 2019-12-11 08:52:22 +10:30
parent 66152f1668
commit b84f6152ee
2 changed files with 6 additions and 2 deletions

View File

@ -1,3 +1,7 @@
2019-12-11 Alan Modra <amodra@gmail.com>
* tic6x-dis.c (tic6x_extract_32): Avoid signed overflow.
2019-12-11 Alan Modra <amodra@gmail.com>
* tic4x-dis.c (tic4x_print_register): Formatting. Don't segfault

View File

@ -163,9 +163,9 @@ static unsigned int
tic6x_extract_32 (unsigned char *p, struct disassemble_info *info)
{
if (info->endian == BFD_ENDIAN_LITTLE)
return (p[0]) | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
return p[0] | (p[1] << 8) | (p[2] << 16) | ((unsigned) p[3] << 24);
else
return (p[3]) | (p[2] << 8) | (p[1] << 16) | (p[0] << 24);
return p[3] | (p[2] << 8) | (p[1] << 16) | ((unsigned) p[0] << 24);
}
/* Extract a 16-bit value read from the instruction stream. */