Fix 'pd.N' cmd, 0size sections, use eprintf r_anal

This commit is contained in:
pancake 2012-08-29 13:37:31 +02:00
parent af45d0ee16
commit 8ecfc21d58
5 changed files with 17 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2010-2011 */
/* radare - LGPL - Copyright 2010-2012 */
/* pancake<nopcode.org> */
#include <r_anal.h>

View File

@ -152,7 +152,7 @@ R_API RAnalType *r_anal_str_to_type(RAnal *a, const char* type) {
while (tTree->next) {
RAnalType *t = tTree->next;
tmp = r_anal_type_to_str (a, t, "; ");
r_cons_printf ("-> (%s)\n", tmp);
eprintf ("-> (%s)\n", tmp);
free (tmp);
tTree = tTree->next;
@ -162,6 +162,7 @@ R_API RAnalType *r_anal_str_to_type(RAnal *a, const char* type) {
// TODO: Add types to RList instead of RAnalType
R_API RAnalType *r_anal_type_loadfile(RAnal *a, const char *path) {
char *tmp;
void *pParser;
char buf[4096];
int n, yv, yylval = 0;
@ -185,5 +186,13 @@ R_API RAnalType *r_anal_type_loadfile(RAnal *a, const char *path) {
// TODO: Parse whole tree and split top-level members
// and place them into RList;
// TODO: insert '.filename' field for all elements in this tree
while (tTree->next) {
RAnalType *t = tTree->next;
tmp = r_anal_type_to_str (a, t, "; ");
eprintf ("-> (%s)\n", tmp);
free (tmp);
tTree = tTree->next;
}
return tTree;
}

View File

@ -223,7 +223,7 @@ static int cmd_print(void *data, const char *input) {
int j, ret, err = 0;
const ut8 *buf = core->block;
if (l==0) l = len;
for (i=j=0; i<core->blocksize && j<len; i+=ret,j++ ) {
for (i=j=0; i<core->blocksize && j<len && j<l; i+=ret,j++ ) {
ret = r_asm_disassemble (core->assembler, &asmop, buf+i, core->blocksize-i);
if (ret<1) {
ret = err = 1;
@ -240,7 +240,7 @@ static int cmd_print(void *data, const char *input) {
int j, ret, err = 0;
const ut8 *buf = core->block;
if (l==0) l = len;
for (i=j=0; i<core->blocksize && j<len; i++,j++ ) {
for (i=j=0; i<core->blocksize && j<len && j<l; i++,j++ ) {
ret = r_asm_disassemble (core->assembler, &asmop, buf+i, core->blocksize-i);
if (ret<1) {
ret = err = 1;

View File

@ -11,7 +11,7 @@ static int cmd_type(void *data, const char *input) {
const char *tname = input + 1;
t = r_anal_type_find (core->anal, tname);
if (t == NULL) eprintf ("Type %s not found!\n", tname);
else r_anal_type_to_str (core->anal, t);
else r_anal_type_to_str (core->anal, t, "; ");
}
break;
// t* - list all types in 'pf' syntax
@ -101,7 +101,7 @@ static int cmd_type(void *data, const char *input) {
RListIter *k;
RAnalType *t;
r_list_foreach (core->anal->types, k, t) {
const char *str = r_anal_type_to_str (core->anal, t);
const char *str = r_anal_type_to_str (core->anal, t, "; ");
r_cons_printf ("%s\n", str);
}
}

View File

@ -34,8 +34,8 @@ R_API void r_io_section_add(RIO *io, ut64 offset, ut64 vaddr, ut64 size, ut64 vs
s = R_NEW (RIOSection);
s->id = io->next_section_id++;
} else update = 1;
if (size>0xf00000) {
eprintf ("Invalid size for section at 0x%08"PFMT64x"\n", vaddr);
if (size==0 || size>0xf00000) {
eprintf ("Invalid size (0x%08"PFMT64x") for section at 0x%08"PFMT64x"\n", size, vaddr);
return;
}
s->offset = offset;