if (address_size != 4 && address_size != 8)
goto invalid;
- /* Ignore the segment size value. */
- // XXX Really?
- (void) *readp++;
+ /* We don't actually support segment selectors. */
+ unsigned int segment_size = *readp++;
+ if (segment_size != 0)
+ goto invalid;
/* Round the address to the next multiple of 2*address_size. */
readp += ((2 * address_size - ((readp - hdrstart) % (2 * address_size)))
+2013-11-09 Mark Wielaard <mjw@redhat.com>
+
+ * arlib.c (arlib_init): Call snprintf before using the result
+ with memcpy.
+ (arlib_finalize): Likewise.
+ * nm.c (show_symbols_sysv): Don't modify cnt inside assert.
+
2013-11-07 Jan Kratochvil <jan.kratochvil@redhat.com>
* Makefile.am (bin_PROGRAMS): Add stack.
_FORTIFY_SOURCE=2 would not let us play these games. Therefore
we play it safe. */
char tmpbuf[sizeof (ar_hdr.ar_date) + 1];
- memcpy (ar_hdr.ar_date, tmpbuf,
- snprintf (tmpbuf, sizeof (tmpbuf), "%-*lld",
+ int s = snprintf (tmpbuf, sizeof (tmpbuf), "%-*lld",
(int) sizeof (ar_hdr.ar_date),
(arlib_deterministic_output ? 0
- : (long long int) time (NULL))));
+ : (long long int) time (NULL)));
+ memcpy (ar_hdr.ar_date, tmpbuf, s);
assert ((sizeof (struct ar_hdr) % sizeof (uint32_t)) == 0);
/* Note the string for the ar_uid and ar_gid cases is longer than
symtab.longnames = obstack_finish (&symtab.longnamesob);
- memcpy (&((struct ar_hdr *) symtab.longnames)->ar_size, tmpbuf,
- snprintf (tmpbuf, sizeof (tmpbuf), "%-*zu",
+ int s = snprintf (tmpbuf, sizeof (tmpbuf), "%-*zu",
(int) sizeof (((struct ar_hdr *) NULL)->ar_size),
- symtab.longnameslen - sizeof (struct ar_hdr)));
+ symtab.longnameslen - sizeof (struct ar_hdr));
+ memcpy (&((struct ar_hdr *) symtab.longnames)->ar_size, tmpbuf, s);
}
symtab.symsofflen = obstack_object_size (&symtab.symsoffob);
{
GElf_Shdr shdr_mem;
- assert (elf_ndxscn (scn) == cnt++);
+ assert (elf_ndxscn (scn) == cnt);
+ cnt++;
char *name = elf_strptr (ebl->elf, shstrndx,
gelf_getshdr (scn, &shdr_mem)->sh_name);