+2021-02-16 Alan Modra <amodra@gmail.com>
+
+ * libbfd.c (_bfd_read_unsigned_leb128): Avoid excessive shift.
+ (_bfd_safe_read_leb128, _bfd_read_signed_leb128): Likewise.
+
2021-02-15 Jan Beulich <jbeulich@suse.com>
* doc/Makefile.am: Replace "cp -p" by "$(LN_S)".
byte = bfd_get_8 (abfd, buf);
buf++;
num_read++;
- result |= (((bfd_vma) byte & 0x7f) << shift);
- shift += 7;
+ if (shift < 8 * sizeof (result))
+ {
+ result |= (((bfd_vma) byte & 0x7f) << shift);
+ shift += 7;
+ }
}
while (byte & 0x80);
*bytes_read_ptr = num_read;
byte = bfd_get_8 (abfd, data);
data++;
num_read++;
-
- result |= ((bfd_vma) (byte & 0x7f)) << shift;
-
- shift += 7;
+ if (shift < 8 * sizeof (result))
+ {
+ result |= ((bfd_vma) (byte & 0x7f)) << shift;
+ shift += 7;
+ }
if ((byte & 0x80) == 0)
break;
}
byte = bfd_get_8 (abfd, buf);
buf ++;
num_read ++;
- result |= (((bfd_vma) byte & 0x7f) << shift);
- shift += 7;
+ if (shift < 8 * sizeof (result))
+ {
+ result |= (((bfd_vma) byte & 0x7f) << shift);
+ shift += 7;
+ }
}
while (byte & 0x80);
if (shift < 8 * sizeof (result) && (byte & 0x40))