mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-01 19:23:04 +00:00
* Fix nullpointer checks in p/bin p9, pe and pe64 when
using virtual files like malloc:// (thanks @vext01 for reporting) * Add search.in=block * Fix search ranges in search.in=file (fixes r2-regressions test)
This commit is contained in:
parent
f79ed42f85
commit
5deffac04f
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2011 nibble<.ds@gmail.com>, pancake<nopcode.org> */
|
||||
/* radare - LGPL - Copyright 2009-2012 nibble<.ds@gmail.com>, pancake<nopcode.org> */
|
||||
|
||||
#include <r_types.h>
|
||||
#include <r_util.h>
|
||||
@ -7,7 +7,9 @@
|
||||
#include "../format/p9/p9bin.h"
|
||||
|
||||
static int check(RBinArch *arch) {
|
||||
return (r_bin_p9_get_arch(arch->buf->buf, NULL, NULL));
|
||||
if (arch && arch->buf && arch->buf->buf)
|
||||
return (r_bin_p9_get_arch (arch->buf->buf, NULL, NULL));
|
||||
return R_FALSE;
|
||||
}
|
||||
|
||||
static int load(RBinArch *arch) {
|
||||
|
@ -213,6 +213,8 @@ static RBinInfo* info(RBinArch *arch) {
|
||||
#if !R_BIN_PE64
|
||||
static int check(RBinArch *arch) {
|
||||
int idx, ret = R_FALSE;
|
||||
if (!arch || !arch->buf || !arch->buf->buf)
|
||||
return R_FALSE;
|
||||
idx = (arch->buf->buf[0x3c]|(arch->buf->buf[0x3d]<<8));
|
||||
if (arch->buf->length>idx)
|
||||
if (!memcmp (arch->buf->buf, "\x4d\x5a", 2) &&
|
||||
|
@ -1,11 +1,13 @@
|
||||
/* radare - LGPL - Copyright 2009-2010 nibble<.ds@gmail.com> */
|
||||
/* radare - LGPL - Copyright 2009-2012 nibble<.ds@gmail.com> */
|
||||
|
||||
#define R_BIN_PE64 1
|
||||
#include "bin_pe.c"
|
||||
|
||||
static int check(RBinArch *arch) {
|
||||
int ret = R_FALSE;
|
||||
int idx = arch->buf->buf[0x3c]|(arch->buf->buf[0x3d]<<8);
|
||||
int idx, ret = R_FALSE;
|
||||
if (!arch || !arch->buf || !arch->buf->buf)
|
||||
return R_FALSE;
|
||||
idx = arch->buf->buf[0x3c]|(arch->buf->buf[0x3d]<<8);
|
||||
if (arch->buf->length>=idx+0x20)
|
||||
if (!memcmp (arch->buf->buf, "\x4d\x5a", 2) &&
|
||||
!memcmp (arch->buf->buf+idx, "\x50\x45", 2) &&
|
||||
|
@ -3827,16 +3827,25 @@ static int cmd_search(void *data, const char *input) {
|
||||
ut8 *buf;
|
||||
|
||||
mode = r_config_get (core->config, "search.in");
|
||||
if (!strcmp (mode, "block")) {
|
||||
from = core->offset;
|
||||
to = core->offset + core->blocksize;
|
||||
} else
|
||||
if (!strcmp (mode, "file")) {
|
||||
if (core->io->va) {
|
||||
ut64 vaddr = 0LL;
|
||||
RListIter *iter;
|
||||
RIOSection *s;
|
||||
from = core->offset;
|
||||
to = from;
|
||||
r_list_foreach (core->io->sections, iter, s) {
|
||||
if ((s->vaddr+s->size) > to)
|
||||
if ((s->vaddr+s->size) > to && from>=s->vaddr) {
|
||||
vaddr = s->vaddr;
|
||||
to = s->vaddr+s->size;
|
||||
}
|
||||
}
|
||||
if (to == 0LL || to == UT64_MAX || to == UT32_MAX)
|
||||
to = r_io_size (core->io);
|
||||
} else {
|
||||
from = core->offset;
|
||||
to = r_io_size (core->io);
|
||||
|
@ -546,7 +546,7 @@ R_API int r_core_config_init(RCore *core) {
|
||||
r_config_set_i_cb (cfg, "scr.cols", 16, &config_scrcols_callback);
|
||||
r_config_desc (cfg, "scr.cols", "Configure the number of columns to print");
|
||||
r_config_set (cfg, "search.in", "file");
|
||||
r_config_desc (cfg, "search.in", "Specify search boundaries. (raw, file, section)");
|
||||
r_config_desc (cfg, "search.in", "Specify search boundaries (raw, block, file, section)");
|
||||
r_config_set_i (cfg, "search.kwidx", 0);
|
||||
r_config_desc (cfg, "search.kwidx", "Store last search index count");
|
||||
r_config_set (cfg, "search.flags", "true");
|
||||
|
Loading…
x
Reference in New Issue
Block a user