Fix invalid free and r2 -hh help

This commit is contained in:
pancake 2014-04-03 23:05:52 +02:00
parent a95cdefae5
commit 613e6e2f9c
5 changed files with 80 additions and 46 deletions

View File

@ -103,12 +103,15 @@ static int main_help(int line) {
" system "R2_PREFIX"/share/radare2/radare2rc\n"
" user ~/.radare2rc ${RHOMEDIR}/radare2/radare2rc\n"
" file ${filename}.r2\n"
"Plugins:\n"
" plugins "R2_PREFIX"/lib/radare2/last\n"
" user ~/.config/radare2/plugins\n"
" LIBR_PLUGINS "R2_PREFIX"/lib/radare2/"R2_VERSION"\n"
"Environment:\n"
" RHOMEDIR ~/.config/radare2\n"
" RCFILE ~/.radare2rc (user preferences, batch script)\n"
" RHOMEDIR ~/.config/radare2\n" // TODO: rename to RHOME R2HOME?
" RCFILE ~/.radare2rc (user preferences, batch script)\n" // TOO GENERIC
" MAGICPATH "R_MAGIC_PATH"\n"
" R_DEBUG if defined, show error messages and crash signal\n"
" LIBR_PLUGINS "R2_PREFIX"/lib/radare2/"R2_VERSION"\n"
" VAPIDIR path to extra vapi directory\n"
);
return 0;
@ -262,31 +265,31 @@ int main(int argc, char **argv, char **envp) {
case 'n': run_anal = 0; break;
case 'N': run_rc = 0; break;
case 'p':
if (*optarg == '-') {
char *path, repath[128];
snprintf (repath, sizeof (repath),
R2_HOMEDIR"/projects/%s.d", optarg+1);
path = r_str_home (repath);
if (r_file_exists (path)) {
if (r_file_rmrf (path) == R_FALSE) {
eprintf ("Unable to recursively remove %s\n", path);
free (path);
return 1;
}
path [strlen (path)-2] = 0;
if (r_file_rm (path) == R_FALSE) {
eprintf ("Unable to remove %s\n", path);
free (path);
return 1;
}
free (path);
return 0;
}
eprintf ("Can't find project '%s'\n", optarg+1);
return 1;
} else r_config_set (r.config, "file.project", optarg);
break;
case 'P': patchfile = optarg; break;
if (*optarg == '-') {
char *path, repath[128];
snprintf (repath, sizeof (repath),
R2_HOMEDIR"/projects/%s.d", optarg+1);
path = r_str_home (repath);
if (r_file_exists (path)) {
if (r_file_rmrf (path) == R_FALSE) {
eprintf ("Unable to recursively remove %s\n", path);
free (path);
return 1;
}
path [strlen (path)-2] = 0;
if (r_file_rm (path) == R_FALSE) {
eprintf ("Unable to remove %s\n", path);
free (path);
return 1;
}
free (path);
return 0;
}
eprintf ("Can't find project '%s'\n", optarg+1);
return 1;
} else r_config_set (r.config, "file.project", optarg);
break;
case 'P': patchfile = optarg; break;
case 'q':
r_config_set (r.config, "scr.interactive", "false");
r_config_set (r.config, "scr.prompt", "false");

View File

@ -215,3 +215,4 @@ EXPLICIT CONTENT
bindings are mostly powered by tears
In Soviet Russia, Radare have documentation
Initial frame selected; you cannot go up.
unk, unk, unk, unk

View File

@ -8,8 +8,8 @@
// Use sdb_vars ?
#define DB a->sdb_fcns
#define EXISTS(x,y...) snprintf (key, sizeof(key)-1,x,##y),sdb_exists(DB,key)
#define SETKEY(x,y...) snprintf (key, sizeof (key)-1, x,##y);
#define EXISTS(x,y...) snprintf (key, sizeof (key)-1, x, ##y), sdb_exists(DB,key)
#define SETKEY(x,y...) snprintf (key, sizeof (key)-1, x, ##y);
// DUPPED FUNCTIONALITY
// kind = char? 'a'rg 'v'var (local, in frame), 'A' fast arg, register
R_API int r_anal_fcn_var_add (RAnal *a, ut64 fna, const char kind, int scope, ut32 index, const char *name, const char *type) {

View File

@ -195,21 +195,15 @@ static void delete_bin_items (RBinObject *o) {
r_list_free (o->lines);
free (o->info);
//free (o->binsym);
o->baddr = 0;
o->boffset = 0;
o->size = 0;
//o->binsym = NULL;
if (o->binsym != NULL) {
ut32 i = 0;
for (i=0; i<R_BIN_SYM_LAST; i++){
free (o->binsym[i]);
o->binsym[i] = NULL;
}
free (o->binsym);//, 0, sizeof (o->binsym));
//o->binsym = NULL;
ut32 i = 0;
for (i=0; i<R_BIN_SYM_LAST; i++){
free (o->binsym[i]);
o->binsym[i] = NULL;
}
o->entries = NULL;
o->fields = NULL;
@ -441,12 +435,10 @@ static void r_bin_free_items(RBin *bin) {
RBINLISTFREE (o->classes);
free (o->info);
o->info = NULL;
if (o->binsym)
for (i=0; i<R_BIN_SYM_LAST; i++){
free (o->binsym[i]);
o->binsym[i] = NULL;
}
for (i=0; i<R_BIN_SYM_LAST; i++){
free (o->binsym[i]);
o->binsym[i] = NULL;
}
if (a->curplugin && a->curplugin->destroy)
a->curplugin->destroy (a);
else free (a->buf);

38
libr/core/p/core_test.c Normal file
View File

@ -0,0 +1,38 @@
/* radare - LGPL - Copyright 2014 - pancake */
#if 0
gcc -o core_test.so -fPIC `pkg-config --cflags --libs r_core` core_test.c -shared
mkdir -p ~/.config/radare2/plugins
mv core_test.so ~/.config/radare2/plugins
#endif
#include <r_types.h>
#include <r_lib.h>
#include <r_cmd.h>
#include <r_core.h>
#include <r_cons.h>
#include <string.h>
#include <r_anal.h>
#undef R_API
#define R_API static
#undef R_IPI
#define R_IPI static
static int r_cmd_test_call() {
eprintf ("Dummy!\n");
return R_FALSE;
}
RCorePlugin r_core_plugin_test = {
.name = "test",
.desc = "lalallala",
.license = "Apache",
.call = r_cmd_test_call,
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
.type = R_LIB_TYPE_CORE,
.data = &r_core_plugin_test
};
#endif