mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-27 15:10:53 +00:00
Fix the DEX crash regression with invalid method names (#7635)
This commit is contained in:
parent
7d1273d09e
commit
f0e1d77a40
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2016 - pancake */
|
||||
/* radare - LGPL - Copyright 2009-2017 - pancake, h4ng3r */
|
||||
|
||||
#include <r_types.h>
|
||||
#include <r_util.h>
|
||||
|
@ -37,8 +37,9 @@ static char *getstr(RBinDexObj *bin, int idx) {
|
||||
ut8 buf[6];
|
||||
ut64 len;
|
||||
int uleblen;
|
||||
if (!bin || idx < 0 || idx >= bin->header.strings_size ||
|
||||
!bin->strings) {
|
||||
// null terminate the buf wtf
|
||||
bin->b->buf[bin->b->length - 1] = 0;
|
||||
if (!bin || idx < 0 || idx >= bin->header.strings_size || !bin->strings) {
|
||||
return "";
|
||||
}
|
||||
if (bin->strings[idx] >= bin->size) {
|
||||
@ -54,10 +55,14 @@ static char *getstr(RBinDexObj *bin, int idx) {
|
||||
if (!len || len >= bin->size) {
|
||||
return "";
|
||||
}
|
||||
char* ptr = (char*) r_buf_get_at(bin->b, bin->strings[idx] + uleblen, NULL);
|
||||
char* ptr = (char*) r_buf_get_at (bin->b, bin->strings[idx] + uleblen, NULL);
|
||||
if (!ptr) {
|
||||
return "";
|
||||
}
|
||||
if (len != strlen (ptr)) {
|
||||
eprintf ("WARNING: Invalid string for index %d\n", idx);
|
||||
return "";
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@ -339,8 +344,7 @@ static void dex_parse_debug_item(RBinFile *binfile, RBinDexObj *bin,
|
||||
return;
|
||||
}
|
||||
|
||||
struct dex_debug_local_t *debug_locals = calloc(sizeof (struct dex_debug_local_t),regsz+1);
|
||||
memset (debug_locals, 0, sizeof (struct dex_debug_local_t) * regsz);
|
||||
struct dex_debug_local_t *debug_locals = calloc (sizeof (struct dex_debug_local_t), regsz + 1);
|
||||
if (!(MA & 0x0008)) {
|
||||
debug_locals[argReg].name = "this";
|
||||
debug_locals[argReg].descriptor = r_str_newf("%s;", class_name);
|
||||
@ -1628,11 +1632,10 @@ static RList* imports(RBinFile *arch) {
|
||||
}
|
||||
|
||||
static RList *methods(RBinFile *arch) {
|
||||
RBinDexObj *bin;
|
||||
if (!arch || !arch->o || !arch->o->bin_obj) {
|
||||
return NULL;
|
||||
}
|
||||
bin = (RBinDexObj*) arch->o->bin_obj;
|
||||
RBinDexObj *bin = (RBinDexObj*) arch->o->bin_obj;
|
||||
if (!bin->methods_list) {
|
||||
dex_loadcode (arch, bin);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user