diff options
author | Alan Modra <amodra@gmail.com> | 2020-08-25 15:46:02 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-08-25 23:07:10 +0930 |
commit | 2186273ac4ba9fa4c56dc8c5d47ab3a7e358cec9 (patch) | |
tree | 634e3e92fd64cbe09af484fdd259d68a3873d976 | |
parent | d3e0baddb206bc7c5ad5beb0c4ac3db8a5feb889 (diff) | |
download | binutils-2186273ac4ba9fa4c56dc8c5d47ab3a7e358cec9.zip binutils-2186273ac4ba9fa4c56dc8c5d47ab3a7e358cec9.tar.gz binutils-2186273ac4ba9fa4c56dc8c5d47ab3a7e358cec9.tar.bz2 |
PR26452, ASAN: som_compute_checksum som.c:4293
PR 26452
* som.c (som_compute_checksum): XOR 32-bit words in header,
not unsigned long sized words.
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/som.c | 11 |
2 files changed, 12 insertions, 5 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 4fc9552..38920f3 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,11 @@ 2020-08-25 Alan Modra <amodra@gmail.com> + PR 26452 + * som.c (som_compute_checksum): XOR 32-bit words in header, + not unsigned long sized words. + +2020-08-25 Alan Modra <amodra@gmail.com> + PR 26430 * elf-nacl.c (nacl_modify_segment_map): Correct alloc size and amount copied for elf_segment_map defined with one element @@ -37,7 +37,7 @@ static bfd_boolean som_mkobject (bfd *); static bfd_boolean som_is_space (asection *); static bfd_boolean som_is_subspace (asection *); static int compare_subspaces (const void *, const void *); -static unsigned long som_compute_checksum (struct som_external_header *); +static uint32_t som_compute_checksum (struct som_external_header *); static bfd_boolean som_build_and_write_symbol_table (bfd *); static unsigned int som_slurp_symbol_table (bfd *); @@ -4281,14 +4281,15 @@ som_finish_writing (bfd *abfd) /* Compute and return the checksum for a SOM file header. */ -static unsigned long +static uint32_t som_compute_checksum (struct som_external_header *hdr) { - unsigned long checksum, count, i; - unsigned long *buffer = (unsigned long *) hdr; + size_t count, i; + uint32_t checksum; + uint32_t *buffer = (uint32_t *) hdr; checksum = 0; - count = sizeof (struct som_external_header) / 4; + count = sizeof (*hdr) / sizeof (*buffer); for (i = 0; i < count; i++) checksum ^= *(buffer + i); |