Fix @b: command suffix for 'pd' and fix issue with malformed mach0

This commit is contained in:
pancake 2014-01-29 02:42:22 +01:00
parent 3d73901849
commit 6e8073a67f
5 changed files with 13 additions and 11 deletions

View file

@ -200,3 +200,7 @@ The Hard ROP Cafe
Please remove pregnant women, pregnant children and pregnant pets from the monitor
Fill the bug. Fill it with love. With the creamy and hot sauce of love.
If you need to escape from hell, 'e asm.arch = malbolge' might help you
Wait a minute! I found a bug, self-fixing... OK
Hold on, this should never happen!
Well this is embarrasing...
THIS IS NOT FUNNY

View file

@ -291,10 +291,8 @@ R_API int r_bin_init_items(RBin *bin, int dummy) {
RBinObject *o = a->o = R_NEW0 (RBinObject);
bin->cur->file = strdup (bin->file);
a->buf = r_buf_mmap (bin->cur->file, 0);
a->size = a->buf ? a->buf->length: 0;
a->curplugin = NULL;
r_list_foreach (bin->plugins, it, plugin) {
@ -405,8 +403,7 @@ static void r_bin_free_items(RBin *bin) {
}
if (a->curplugin && a->curplugin->destroy)
a->curplugin->destroy (a);
else if (a->buf) free (a->buf);
else free (a->buf);
free (a->file);
memset (a, 0, sizeof(RBinFile));

View file

@ -446,13 +446,14 @@ static int prot2perm (int x) {
struct r_bin_mach0_section_t* MACH0_(r_bin_mach0_get_sections)(struct MACH0_(r_bin_mach0_obj_t)* bin) {
struct r_bin_mach0_section_t *sections;
char segname[17], sectname[17];
int i, j;
int i, j, to;
if (!bin->sects)
return NULL;
to = R_MIN (bin->nsects, 128); // limit number of sections here to avoid fuzzed bins
if (!(sections = malloc ((bin->nsects + 1) * sizeof (struct r_bin_mach0_section_t))))
return NULL;
for (i = 0; i<bin->nsects; i++) {
for (i = 0; i<to; i++) {
sections[i].offset = (ut64)bin->sects[i].offset;
sections[i].addr = (ut64)bin->sects[i].addr;
sections[i].size = (ut64)bin->sects[i].size;

View file

@ -1,4 +1,3 @@
/* radare - LGPL - Copyright 2009-2014 - pancake, nibble, Adam Pridgen <dso@rice.edu || adam.pridgen@thecoverofnight.com> */
#include <r_types.h>
@ -138,6 +137,7 @@ static int check(RBinFile *arch) {
if (!memcmp (arch->buf->buf, "\xca\xfe\xba\xbe", 4)) {
memcpy (&off, arch->buf->buf+4*sizeof(int), sizeof(int));
r_mem_copyendian ((ut8*)&off, (ut8*)&off, sizeof(int), !LIL_ENDIAN);
// TODO: FIND __TEXT
ret = R_TRUE;
}
return ret;

View file

@ -858,9 +858,7 @@ static int cmd_print(void *data, const char *input) {
ignore_invalid = R_FALSE;
bwdhits = r_core_asm_back_disassemble_byte (core,
core->offset, use_blocksize, -1, 0);
}
else
bwdhits = r_core_asm_back_disassemble_instr (core,
} else bwdhits = r_core_asm_back_disassemble_instr (core,
core->offset, use_blocksize, -1, 0);
if (bwdhits) {
@ -940,7 +938,7 @@ static int cmd_print(void *data, const char *input) {
int ret, err = 0;
ut8 *buf = core->block;
if (l<1) l = len;
if (l>=core->blocksize) {
if (l>core->blocksize) {
buf = malloc (l+1);
r_core_read_at (core, core->offset, buf, l);
}
@ -1116,7 +1114,9 @@ static int cmd_print(void *data, const char *input) {
core, addr, block, l, l, 0, 1);
} else {
block = malloc (l*10);
if (l>core->blocksize)
r_core_read_at (core, addr, block, l*10); //core->blocksize);
else memcpy (block, core->block, core->blocksize);
core->num->value = r_core_print_disasm (core->print,
core, addr, block, l*10, l, 0, 0);
}