Fix an off-by-one error when checking whether a given address is within

the extent of a symbol.

Submitted by:	Prashanth Kumar <pra_udupi@yahoo.co.in>
Reviewed by:	rpaulo
MFC after:	1 week
This commit is contained in:
markj 2013-10-29 03:52:05 +00:00
parent 25971e06a2
commit 756d4686b3

View File

@ -285,7 +285,7 @@ proc_addr2sym(struct proc_handle *p, uintptr_t addr, char *name,
* by rtld. * by rtld.
*/ */
rsym = map->pr_vaddr + sym.st_value; rsym = map->pr_vaddr + sym.st_value;
if (addr >= rsym && addr <= (rsym + sym.st_size)) { if (addr >= rsym && addr < rsym + sym.st_size) {
s = elf_strptr(e, dynsymstridx, sym.st_name); s = elf_strptr(e, dynsymstridx, sym.st_name);
if (s) { if (s) {
if (s[0] == '_' && s[1] == 'Z' && s[2]) if (s[0] == '_' && s[1] == 'Z' && s[2])
@ -325,7 +325,7 @@ symtab:
rsym = map->pr_vaddr + sym.st_value; rsym = map->pr_vaddr + sym.st_value;
else else
rsym = sym.st_value; rsym = sym.st_value;
if (addr >= rsym && addr <= (rsym + sym.st_size)) { if (addr >= rsym && addr < rsym + sym.st_size) {
s = elf_strptr(e, symtabstridx, sym.st_name); s = elf_strptr(e, symtabstridx, sym.st_name);
if (s) { if (s) {
if (s[0] == '_' && s[1] == 'Z' && s[2]) if (s[0] == '_' && s[1] == 'Z' && s[2])