mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-14 00:38:55 +00:00
Fix r_str_nlen for trashed symbols
This commit is contained in:
parent
7eea922f35
commit
561555a595
@ -9,15 +9,6 @@
|
||||
|
||||
static ut64 Elf_(r_bin_elf_get_section_offset)(struct Elf_(r_bin_elf_obj_t) *bin, const char *section_name);
|
||||
|
||||
static inline int __strnlen(const char *str, int len) {
|
||||
int l = 0;
|
||||
while (*str && --len) {
|
||||
str++;
|
||||
l++;
|
||||
}
|
||||
return l+1;
|
||||
}
|
||||
|
||||
static int Elf_(r_bin_elf_init_ehdr)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
||||
ut8 e_ident[EI_NIDENT];
|
||||
int len;
|
||||
@ -1184,7 +1175,7 @@ if (
|
||||
free (strtab);
|
||||
return NULL;
|
||||
}
|
||||
len = __strnlen (&strtab[sym[k].st_name], ELF_STRING_LENGTH-1);
|
||||
len = r_str_nlen (strtab+sym[k].st_name, ELF_STRING_LENGTH-1);
|
||||
memcpy (ret[ret_ctr].name, &strtab[sym[k].st_name], len);
|
||||
ret[ret_ctr].ordinal = k;
|
||||
ret[ret_ctr].name[ELF_STRING_LENGTH-2] = '\0';
|
||||
|
@ -894,8 +894,13 @@ R_API int r_str_ansi_len(const char *str) {
|
||||
// TODO: support wide char strings
|
||||
R_API int r_str_nlen(const char *str, int n) {
|
||||
int len = 0;
|
||||
while (*str++ && n--)
|
||||
len++;
|
||||
if (str) {
|
||||
while (IS_PRINTABLE (*str) && n>0) {
|
||||
len++;
|
||||
str++;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user