[rtems commit] libdl: Fix possible 16-bit overflow (Coverity 1255339) refs #2192.

Chris Johns chrisj at rtems.org
Wed Nov 19 23:20:04 UTC 2014


Module:    rtems
Branch:    master
Commit:    fc523ac86987570823e1dcfd18b9938c652aeae8
Changeset: http://git.rtems.org/rtems/commit/?id=fc523ac86987570823e1dcfd18b9938c652aeae8

Author:    Chris Johns <chrisj at rtems.org>
Date:      Thu Nov 20 10:18:16 2014 +1100

libdl: Fix possible 16-bit overflow (Coverity 1255339) refs #2192.

On a 16-bit target the section value could result in a sign-extension
overflow.

---

 cpukit/libdl/rtl-elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpukit/libdl/rtl-elf.c b/cpukit/libdl/rtl-elf.c
index 46f5613..3a432aa 100644
--- a/cpukit/libdl/rtl-elf.c
+++ b/cpukit/libdl/rtl-elf.c
@@ -639,7 +639,7 @@ rtems_rtl_elf_parse_sections (rtems_rtl_obj_t* obj, int fd, Elf_Ehdr* ehdr)
   {
     uint32_t flags;
 
-    off = obj->ooffset + ehdr->e_shoff + (section * ehdr->e_shentsize);
+    off = obj->ooffset + ehdr->e_shoff + (((uint32_t) section) * ehdr->e_shentsize);
 
     if (!rtems_rtl_obj_cache_read_byval (sects, fd, off, &shdr, sizeof (shdr)))
       return false;




More information about the vc mailing list