Aim to fix eeaf87ece627fe94f92f836ac3467ffd @revskills dyldcache crash

This commit is contained in:
pancake 2015-10-26 03:45:54 +01:00
parent b312439484
commit 02e719fafe
3 changed files with 14 additions and 13 deletions

View File

@ -39,8 +39,12 @@ struct r_bin_dyldcache_lib_t *r_bin_dyldcache_extract(struct r_bin_dyldcache_obj
perror ("malloc (ret)");
return NULL;
}
curoffset = bin->hdr.startaddr+idx*32;
libla = *(ut64*)(bin->b->buf+curoffset);
curoffset = bin->hdr.startaddr + idx * 32;
if (curoffset+8 >= bin->size) {
perror ("oob thing");
return NULL;
}
libla = *(ut64*)(bin->b->buf + curoffset);
liboff = libla - *(ut64*)&bin->b->buf[bin->hdr.baseaddroff];
if (liboff > bin->size) {
eprintf ("Corrupted file\n");

View File

@ -1638,6 +1638,7 @@ static int bin_classes(RCore *r, int mode) {
r_list_foreach (c->methods, iter2, sym) {
snprintf (str, sizeof (str),
"method.%s.%s", c->name, sym->name);
str[sizeof(str)-1] = 0;
r_name_filter (str, 0);
r_flag_set (r->flags, str, sym->vaddr, 1, 0);
}

View File

@ -481,18 +481,15 @@ R_API char *r_str_chop(char *str) {
int len;
char *ptr;
if (str == NULL)
return NULL;
if (!str) return NULL;
while (*str && iswhitechar (*str))
memmove (str, str + 1, strlen (str + 1) + 1);
len = strlen (str);
if (len>0)
for (ptr = str + len-1; ptr != str; ptr--) {
if (iswhitechar (*ptr)) *ptr = '\0';
else break;
if (len > 0) {
for (ptr = str + len-1; ptr != str; ptr--) {
if (!iswhitechar (*ptr)) break;
*ptr = '\0';
}
}
return str;
}
@ -547,8 +544,7 @@ R_API char *r_str_trim_head_tail(char *str) {
R_API char *r_str_trim(char *str) {
int i;
char *ptr;
if (str == NULL)
return NULL;
if (!str) return NULL;
for (ptr = str, i=0; str[i]; i++)
if (!iswhitechar (str[i]))
*ptr++ = str[i];