public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [patch] msp430: avoid overflow
@ 2014-05-20 19:42 DJ Delorie
  0 siblings, 0 replies; only message in thread
From: DJ Delorie @ 2014-05-20 19:42 UTC (permalink / raw)
  To: binutils


Avoid reading past the end of the local symbols array.  Committed.

	* elf32-msp430.c (msp430_elf_relax_adjust_locals): Avoid overflow.

diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c
index c2d168c..2f55c53 100644
--- a/bfd/elf32-msp430.c
+++ b/bfd/elf32-msp430.c
@@ -1582,14 +1582,15 @@ msp430_elf_relax_adjust_locals (bfd * abfd, asection * sec, bfd_vma addr,
   irelend = irel + sec->reloc_count;
   symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
   isym = (Elf_Internal_Sym *) symtab_hdr->contents;
-  
+
   for (;irel < irelend; irel++)
     {
-      int sidx = ELF32_R_SYM(irel->r_info);
+      unsigned int sidx = ELF32_R_SYM(irel->r_info);
       Elf_Internal_Sym *lsym = isym + sidx;
-      
+
       /* Adjust symbols referenced by .sec+0xXX */
-      if (irel->r_addend > addr && irel->r_addend < toaddr 
+      if (irel->r_addend > addr && irel->r_addend < toaddr
+	  && sidx < symtab_hdr->sh_info
 	  && lsym->st_shndx == sec_shndx)
 	irel->r_addend -= count;
     }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-05-20 19:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-20 19:42 [patch] msp430: avoid overflow DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).