Makes the code a little more elegant too. Note that the unsigned
overflow reported here is well defined so this patch doesn't fix any
real problem.
PR 27291
* section.c (bfd_get_section_contents): Avoid possible overflow
when range checking offset and count.
(bfd_set_section_contents): Likewise.
+2021-02-11 Alan Modra <amodra@gmail.com>
+
+ PR 27291
+ * section.c (bfd_get_section_contents): Avoid possible overflow
+ when range checking offset and count.
+ (bfd_set_section_contents): Likewise.
+
2021-02-03 Nick Alcock <nick.alcock@oracle.com>
* configure.ac (SHARED_LIBADD): Remove explicit -lintl population in
sz = section->size;
if ((bfd_size_type) offset > sz
- || count > sz
- || offset + count > sz
+ || count > sz - offset
|| count != (size_t) count)
{
bfd_set_error (bfd_error_bad_value);
else
sz = section->size;
if ((bfd_size_type) offset > sz
- || count > sz
- || offset + count > sz
+ || count > sz - offset
|| count != (size_t) count)
{
bfd_set_error (bfd_error_bad_value);