[Forensics-changes] [yara] 105/415: Fix some integer checks in elf_rva_to_offset_32 (issue 16)
Hilko Bengen
bengen at moszumanska.debian.org
Thu Apr 3 05:42:51 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch debian
in repository yara.
commit 42a5670c7b5c755e817cb7953635a7291e4dc944
Author: Victor M. Alvarez <plusvic at gmail.com>
Date: Mon Aug 1 09:41:37 2011 +0000
Fix some integer checks in elf_rva_to_offset_32 (issue 16)
---
libyara/exe.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libyara/exe.c b/libyara/exe.c
index 4793046..5e167aa 100644
--- a/libyara/exe.c
+++ b/libyara/exe.c
@@ -24,6 +24,7 @@ GNU General Public License for more details.
#include "elf.h"
+
#ifndef NULL
#define NULL 0
#endif
@@ -135,7 +136,7 @@ unsigned long long elf_rva_to_offset_32(Elf32_Ehdr* elf_header, unsigned long lo
return 0;
// check to prevent integer wraps
- if(ULLONG_MAX - elf_header->e_shoff < sizeof(Elf64_Shdr) * elf_header->e_shnum)
+ if(ULONG_MAX - elf_header->e_shoff < sizeof(Elf32_Shdr) * elf_header->e_shnum)
return 0;
if (elf_header->e_shoff + sizeof(Elf32_Shdr) * elf_header->e_shnum > buffer_length)
@@ -151,10 +152,10 @@ unsigned long long elf_rva_to_offset_32(Elf32_Ehdr* elf_header, unsigned long lo
rva < section->sh_addr + section->sh_size)
{
// prevent integer wrapping with the return value
- if (ULLONG_MAX - section->sh_offset < (rva - section->sh_addr))
+ if (ULONG_MAX - section->sh_offset < (rva - section->sh_addr))
return 0;
else
- return section->sh_offset + (rva - section->sh_addr);
+ return section->sh_offset + (rva - section->sh_addr);
}
section++;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git
More information about the forensics-changes
mailing list