dwarf.c (read_uleb128): Fix overflow test.
* dwarf.c (read_uleb128): Fix overflow test. (read_sleb128): Likewise. (build_address_map): Don't change unit_buf.start. From-SVN: r192053
This commit is contained in:
parent
91ba65f2f0
commit
be4ba8aef3
@ -1,3 +1,9 @@
|
|||||||
|
2012-10-03 Ian Lance Taylor <iant@google.com>
|
||||||
|
|
||||||
|
* dwarf.c (read_uleb128): Fix overflow test.
|
||||||
|
(read_sleb128): Likewise.
|
||||||
|
(build_address_map): Don't change unit_buf.start.
|
||||||
|
|
||||||
2012-10-02 Uros Bizjak <ubizjak@gmail.com>
|
2012-10-02 Uros Bizjak <ubizjak@gmail.com>
|
||||||
|
|
||||||
PR other/54761
|
PR other/54761
|
||||||
|
@ -524,10 +524,12 @@ read_uleb128 (struct dwarf_buf *buf)
|
|||||||
{
|
{
|
||||||
uint64_t ret;
|
uint64_t ret;
|
||||||
unsigned int shift;
|
unsigned int shift;
|
||||||
|
int overflow;
|
||||||
unsigned char b;
|
unsigned char b;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
shift = 0;
|
shift = 0;
|
||||||
|
overflow = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
const unsigned char *p;
|
const unsigned char *p;
|
||||||
@ -536,14 +538,17 @@ read_uleb128 (struct dwarf_buf *buf)
|
|||||||
if (!advance (buf, 1))
|
if (!advance (buf, 1))
|
||||||
return 0;
|
return 0;
|
||||||
b = *p;
|
b = *p;
|
||||||
ret |= ((uint64_t) (b & 0x7f)) << shift;
|
if (shift < 64)
|
||||||
|
ret |= ((uint64_t) (b & 0x7f)) << shift;
|
||||||
|
else if (!overflow)
|
||||||
|
{
|
||||||
|
dwarf_buf_error (buf, "LEB128 overflows uint64_t");
|
||||||
|
overflow = 1;
|
||||||
|
}
|
||||||
shift += 7;
|
shift += 7;
|
||||||
}
|
}
|
||||||
while ((b & 0x80) != 0);
|
while ((b & 0x80) != 0);
|
||||||
|
|
||||||
if (shift > 64)
|
|
||||||
dwarf_buf_error (buf, "LEB128 overflows uint64_5");
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -554,10 +559,12 @@ read_sleb128 (struct dwarf_buf *buf)
|
|||||||
{
|
{
|
||||||
uint64_t val;
|
uint64_t val;
|
||||||
unsigned int shift;
|
unsigned int shift;
|
||||||
|
int overflow;
|
||||||
unsigned char b;
|
unsigned char b;
|
||||||
|
|
||||||
val = 0;
|
val = 0;
|
||||||
shift = 0;
|
shift = 0;
|
||||||
|
overflow = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
const unsigned char *p;
|
const unsigned char *p;
|
||||||
@ -566,15 +573,18 @@ read_sleb128 (struct dwarf_buf *buf)
|
|||||||
if (!advance (buf, 1))
|
if (!advance (buf, 1))
|
||||||
return 0;
|
return 0;
|
||||||
b = *p;
|
b = *p;
|
||||||
val |= ((uint64_t) (b & 0x7f)) << shift;
|
if (shift < 64)
|
||||||
|
val |= ((uint64_t) (b & 0x7f)) << shift;
|
||||||
|
else if (!overflow)
|
||||||
|
{
|
||||||
|
dwarf_buf_error (buf, "signed LEB128 overflows uint64_t");
|
||||||
|
overflow = 1;
|
||||||
|
}
|
||||||
shift += 7;
|
shift += 7;
|
||||||
}
|
}
|
||||||
while ((b & 0x80) != 0);
|
while ((b & 0x80) != 0);
|
||||||
|
|
||||||
if (shift > 64)
|
if ((b & 0x40) != 0 && shift < 64)
|
||||||
dwarf_buf_error (buf, "signed LEB128 overflows uint64_t");
|
|
||||||
|
|
||||||
if ((b & 0x40) != 0)
|
|
||||||
val |= ((uint64_t) -1) << shift;
|
val |= ((uint64_t) -1) << shift;
|
||||||
|
|
||||||
return (int64_t) val;
|
return (int64_t) val;
|
||||||
@ -1262,7 +1272,6 @@ build_address_map (struct backtrace_state *state,
|
|||||||
}
|
}
|
||||||
|
|
||||||
unit_buf = info;
|
unit_buf = info;
|
||||||
unit_buf.start = info.buf;
|
|
||||||
unit_buf.left = len;
|
unit_buf.left = len;
|
||||||
|
|
||||||
if (!advance (&info, len))
|
if (!advance (&info, len))
|
||||||
|
Loading…
Reference in New Issue
Block a user