libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libunwind-devel] [PATCH] Fix incorrect return code of unw_get_proc_name


From: Martin Milata
Subject: [Libunwind-devel] [PATCH] Fix incorrect return code of unw_get_proc_name
Date: Mon, 6 Aug 2012 20:15:20 +0200

The code for symbol lookup (elfxx.c:lookup_symbol) works by iterating
over symbol tables while maintaing the symbol closest to the supplied
instruction pointer. Whenever this search encountered symbol that was
longer than result buffer, the function returned -UNW_ENOMEM even though
the final symbol wasn't too long.

Signed-off-by: Martin Milata <address@hidden>
---
 src/elfxx.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/elfxx.c b/src/elfxx.c
index 844cc1c..2d5aacc 100644
--- a/src/elfxx.c
+++ b/src/elfxx.c
@@ -41,7 +41,7 @@ elf_w (lookup_symbol) (unw_addr_space_t as,
   Elf_W (Off) soff, str_soff;
   Elf_W (Shdr) *shdr, *str_shdr;
   Elf_W (Addr) val, min_dist = ~(Elf_W (Addr))0;
-  int i, ret = 0;
+  int i, ret = -UNW_ENOINFO;
   char *strtab;
 
   if (!elf_w (valid_object) (ei))
@@ -102,8 +102,8 @@ elf_w (lookup_symbol) (unw_addr_space_t as,
                      min_dist = (Elf_W (Addr)) (ip - val);
                      strncpy (buf, strtab + sym->st_name, buf_len);
                      buf[buf_len - 1] = '\0';
-                     if (strlen (strtab + sym->st_name) >= buf_len)
-                       ret = -UNW_ENOMEM;
+                     ret = (strlen (strtab + sym->st_name) >= buf_len
+                            ? -UNW_ENOMEM : 0);
                    }
                }
            }
-- 
1.7.7.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]