mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-19 12:22:43 +00:00
* Use null fot unsupported plugins
* Fix startup segfault in r_reg doublefree
This commit is contained in:
parent
ce1d0e9975
commit
c7cced5c67
@ -1,4 +1,4 @@
|
|||||||
/* radare - LGPL - Copyright 2009 */
|
/* radare - LGPL - Copyright 2009-2011 */
|
||||||
/* nibble<.ds@gmail.com> */
|
/* nibble<.ds@gmail.com> */
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -10,14 +10,10 @@
|
|||||||
|
|
||||||
#include "x86/x86im/x86im.h"
|
#include "x86/x86im/x86im.h"
|
||||||
|
|
||||||
static const char *gpr8[] = {
|
static const char *gpr8[] = { "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" };
|
||||||
"al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" };
|
static const char *gpr8b[] = { "spl", "bpl", "sil", "dil" };
|
||||||
static const char *gpr8b[] = {
|
static const char *gpr16[] = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di" };
|
||||||
"spl", "bpl", "sil", "dil" };
|
static const char *gpr32[] = { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" };
|
||||||
static const char *gpr16[] = {
|
|
||||||
"ax", "cx", "dx", "bx", "sp", "bp", "si", "di" };
|
|
||||||
static const char *gpr32[] = {
|
|
||||||
"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" };
|
|
||||||
static const char *gpr64[] = {
|
static const char *gpr64[] = {
|
||||||
"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
|
"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
|
||||||
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" };
|
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" };
|
||||||
|
@ -142,6 +142,8 @@ R_API int r_asm_add(RAsm *a, RAsmPlugin *foo) {
|
|||||||
RListIter *iter;
|
RListIter *iter;
|
||||||
RAsmPlugin *h;
|
RAsmPlugin *h;
|
||||||
// TODO: cache foo->name length and use memcmp instead of strcmp
|
// TODO: cache foo->name length and use memcmp instead of strcmp
|
||||||
|
if (!foo->name)
|
||||||
|
return R_FALSE;
|
||||||
if (foo->init)
|
if (foo->init)
|
||||||
foo->init (a->user);
|
foo->init (a->user);
|
||||||
r_list_foreach (a->plugins, iter, h)
|
r_list_foreach (a->plugins, iter, h)
|
||||||
|
@ -92,8 +92,8 @@ LIB=lib${NAME}
|
|||||||
LIBAR=${LIB}.${EXT_AR}
|
LIBAR=${LIB}.${EXT_AR}
|
||||||
LIBSO=${LIB}.${EXT_SO}
|
LIBSO=${LIB}.${EXT_SO}
|
||||||
ifeq (${OSTYPE},android)
|
ifeq (${OSTYPE},android)
|
||||||
libname=-shared -o ${LDFLAGS_SONAME}$1.${EXT_SO}
|
libname=-shared -o $1.${EXT_SO} ${LDFLAGS_SONAME}$1.${EXT_SO}
|
||||||
else
|
else
|
||||||
libname=-shared -o ${LDFLAGS_SONAME}$1.${EXT_SO}.${LIBVERSION}
|
libname=-shared -o $1.${EXT_SO} ${LDFLAGS_SONAME}$1.${EXT_SO}.${LIBVERSION}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ R_API int r_debug_plugin_list(RDebug *dbg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
R_API int r_debug_plugin_add(RDebug *dbg, RDebugPlugin *foo) {
|
R_API int r_debug_plugin_add(RDebug *dbg, RDebugPlugin *foo) {
|
||||||
|
if (!foo->name) return R_FALSE;
|
||||||
list_add_tail (&(foo->list), &(dbg->plugins));
|
list_add_tail (&(foo->list), &(dbg->plugins));
|
||||||
return R_TRUE;
|
return R_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ static RIODesc *__open(struct r_io_t *io, const char *pathname, int rw, int mode
|
|||||||
|
|
||||||
struct r_io_plugin_t r_io_plugin_http = {
|
struct r_io_plugin_t r_io_plugin_http = {
|
||||||
.name = "http",
|
.name = "http",
|
||||||
.desc = "http get ( http://www.radare.org/ )",
|
.desc = "http get (http://radare.org/)",
|
||||||
.open = __open,
|
.open = __open,
|
||||||
.close = __close,
|
.close = __close,
|
||||||
.read = __read,
|
.read = __read,
|
||||||
|
@ -248,7 +248,7 @@ static int __system(struct r_io_t *io, RIODesc *fd, const char *cmd) {
|
|||||||
// TODO: rename ptrace to io_mach .. err io.ptrace ??
|
// TODO: rename ptrace to io_mach .. err io.ptrace ??
|
||||||
struct r_io_plugin_t r_io_plugin_mach = {
|
struct r_io_plugin_t r_io_plugin_mach = {
|
||||||
.name = "mach",
|
.name = "mach",
|
||||||
.desc = "mach debug io",
|
.desc = "mach debugger io plugin (mach://pid)",
|
||||||
.open = __open,
|
.open = __open,
|
||||||
.close = __close,
|
.close = __close,
|
||||||
.read = __read,
|
.read = __read,
|
||||||
|
@ -84,7 +84,7 @@ static RIODesc *__open(struct r_io_t *io, const char *pathname, int rw, int mode
|
|||||||
|
|
||||||
struct r_io_plugin_t r_io_plugin_malloc = {
|
struct r_io_plugin_t r_io_plugin_malloc = {
|
||||||
.name = "malloc",
|
.name = "malloc",
|
||||||
.desc = "memory allocation ( malloc://size-in-bytes )",
|
.desc = "memory allocation (malloc://1024)",
|
||||||
.open = __open,
|
.open = __open,
|
||||||
.close = __close,
|
.close = __close,
|
||||||
.read = __read,
|
.read = __read,
|
||||||
|
@ -144,8 +144,7 @@ struct r_io_plugin_t r_io_plugin_procpid = {
|
|||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
struct r_io_plugin_t r_io_plugin_procpid = {
|
struct r_io_plugin_t r_io_plugin_procpid = {
|
||||||
.name = "procpid",
|
.name = NULL
|
||||||
.desc = "proc/pid/mem io (NOT SUPPORTED FOR THIS PLATFORM)",
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -179,8 +179,7 @@ struct r_io_plugin_t r_io_plugin_ptrace = {
|
|||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
struct r_io_plugin_t r_io_plugin_ptrace = {
|
struct r_io_plugin_t r_io_plugin_ptrace = {
|
||||||
.name = "ptrace",
|
.name = NULL
|
||||||
.desc = "ptrace io (NOT SUPPORTED FOR THIS PLATFORM)",
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -125,8 +125,7 @@ struct r_io_plugin_t r_io_plugin_w32dbg = {
|
|||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
struct r_io_plugin_t r_io_plugin_w32dbg = {
|
struct r_io_plugin_t r_io_plugin_w32dbg = {
|
||||||
.name = "w32dbg",
|
.name = NULL
|
||||||
.desc = "w32dbg io (NOT SUPPORTED FOR THIS PLATFORM)",
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ R_API int r_io_plugin_init(RIO *io) {
|
|||||||
|
|
||||||
INIT_LIST_HEAD (&io->io_list);
|
INIT_LIST_HEAD (&io->io_list);
|
||||||
for (i=0; io_static_plugins[i]; i++) {
|
for (i=0; io_static_plugins[i]; i++) {
|
||||||
|
if (!io_static_plugins[i]->name)
|
||||||
|
continue;
|
||||||
static_plugin = R_NEW (RIOPlugin);
|
static_plugin = R_NEW (RIOPlugin);
|
||||||
memcpy (static_plugin, io_static_plugins[i], sizeof (RIOPlugin));
|
memcpy (static_plugin, io_static_plugins[i], sizeof (RIOPlugin));
|
||||||
r_io_plugin_add (io, static_plugin);
|
r_io_plugin_add (io, static_plugin);
|
||||||
|
@ -123,8 +123,8 @@ R_API int r_lib_dl_check_filename(const char *file) {
|
|||||||
|
|
||||||
R_API int r_lib_run_handler(RLib *lib, RLibPlugin *plugin, RLibStruct *symbol) {
|
R_API int r_lib_run_handler(RLib *lib, RLibPlugin *plugin, RLibStruct *symbol) {
|
||||||
RLibHandler *h = plugin->handler;
|
RLibHandler *h = plugin->handler;
|
||||||
if (h && h->constructor != NULL)
|
if (h && h->constructor)
|
||||||
return h->constructor(plugin, h->user, symbol->data);
|
return h->constructor (plugin, h->user, symbol->data);
|
||||||
return R_FAIL;
|
return R_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ static int samefile(const char *a, const char *b) {
|
|||||||
len = strlen (ptr+1) + 1;
|
len = strlen (ptr+1) + 1;
|
||||||
memmove (ptr, ptr+1, len);
|
memmove (ptr, ptr+1, len);
|
||||||
}
|
}
|
||||||
} while(ptr);
|
} while (ptr);
|
||||||
do {
|
do {
|
||||||
ptr = strstr(sb, "//");
|
ptr = strstr(sb, "//");
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
@ -187,7 +187,7 @@ R_API int r_lib_open(RLib *lib, const char *file) {
|
|||||||
RLibPlugin *p;
|
RLibPlugin *p;
|
||||||
RListIter *iter;
|
RListIter *iter;
|
||||||
RLibStruct *stru;
|
RLibStruct *stru;
|
||||||
void * handler;
|
void *handler;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* ignored by filename */
|
/* ignored by filename */
|
||||||
@ -317,6 +317,7 @@ R_API void r_lib_list(RLib *lib) {
|
|||||||
#endif
|
#endif
|
||||||
//printf("Loaded plugins:\n");
|
//printf("Loaded plugins:\n");
|
||||||
r_list_foreach (lib->plugins, iter, p) {
|
r_list_foreach (lib->plugins, iter, p) {
|
||||||
printf(" %5s %p %s \n", r_lib_types_get(p->type), p->handler->destructor, p->file);
|
printf (" %5s %p %s \n", r_lib_types_get (p->type),
|
||||||
|
p->handler->destructor, p->file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,12 +10,12 @@ STATIC_OBJS=$(subst ..,p/..,$(subst parse_,p/parse_,$(STATIC_OBJ)))
|
|||||||
OBJ=parse.o ${STATIC_OBJS}
|
OBJ=parse.o ${STATIC_OBJS}
|
||||||
|
|
||||||
bins:
|
bins:
|
||||||
cd t && ${MAKE} all
|
@cd t && ${MAKE} all
|
||||||
|
|
||||||
pre:
|
pre:
|
||||||
@if [ ! -e libr_parse.${EXT_SO} ]; then rm -f ${STATIC_OBJS} ; fi
|
@if [ ! -e libr_parse.${EXT_SO} ]; then rm -f ${STATIC_OBJS} ; fi
|
||||||
|
|
||||||
plugins:
|
plugins:
|
||||||
cd p && ${MAKE} all
|
@cd p && ${MAKE} all
|
||||||
|
|
||||||
include ../rules.mk
|
include ../rules.mk
|
||||||
|
@ -9,7 +9,7 @@ CFLAGS+=-DCORELIB
|
|||||||
foo: all
|
foo: all
|
||||||
|
|
||||||
ALL_TARGETS=
|
ALL_TARGETS=
|
||||||
ARCHS=x86_pseudo.mk mreplace.mk
|
ARCHS=att2intel.mk x86_pseudo.mk mreplace.mk
|
||||||
include $(ARCHS)
|
include $(ARCHS)
|
||||||
|
|
||||||
all: ${ALL_TARGETS}
|
all: ${ALL_TARGETS}
|
||||||
|
@ -53,7 +53,7 @@ R_API void r_reg_free_internal(RReg *reg) {
|
|||||||
int i;
|
int i;
|
||||||
for (i=0; i<R_REG_TYPE_LAST; i++) {
|
for (i=0; i<R_REG_TYPE_LAST; i++) {
|
||||||
r_list_destroy (reg->regset[i].regs);
|
r_list_destroy (reg->regset[i].regs);
|
||||||
reg->regset[i].regs = NULL;
|
R_LIST_NEW (reg->regset[i].regs, r_reg_item_free);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,8 +187,10 @@ R_API int r_reg_set_profile_string(RReg *reg, const char *str) {
|
|||||||
else if (word>3) {
|
else if (word>3) {
|
||||||
r_reg_set_word (item, word, buf);
|
r_reg_set_word (item, word, buf);
|
||||||
if (item->name != NULL) {
|
if (item->name != NULL) {
|
||||||
r_list_append (reg->regset[item->type].regs, item);
|
if (reg->regset[item->type].regs) {
|
||||||
item = r_reg_item_new ();
|
r_list_append (reg->regset[item->type].regs, item);
|
||||||
|
item = r_reg_item_new ();
|
||||||
|
} else eprintf ("REGSET is null wtf\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chidx = word = 0;
|
chidx = word = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user