Fix build and several queues covs from previous analysis

This commit is contained in:
pancake 2017-04-26 12:47:27 +02:00
parent ff0d724c60
commit 5433af7cb0
6 changed files with 27 additions and 26 deletions

View File

@ -373,6 +373,7 @@ static void extract_arg(RAnal *anal, RAnalFunction *fcn, RAnalOp *op, const char
st64 ptr;
char *sig = r_str_newf (",%s,%s", reg, sign);
if (!sig || !anal) {
free (sig);
return;
}
op_esil = r_strbuf_get (&op->esil);

View File

@ -32,8 +32,7 @@ static bool check_bytes(const ut8 *buf, ut64 length) {
}
static void * load_bytes(RBinFile *arch, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb){
check_bytes (buf, sz);
return R_NOTNULL;
return check_bytes (buf, sz) ? R_NOTNULL : NULL;
}
static RBinInfo* info(RBinFile *arch) {
@ -154,10 +153,12 @@ static RList* sections(RBinFile *arch) {
}
if (is_hirom) {
for (i=0; i < ((arch->size - hdroffset)/ 0x8000) ; i++) {
addrom(ret,"ROM",i,hdroffset + i*0x8000,0x400000 + (i*0x8000), 0x8000);
if (i % 2) addrom(ret,"ROM_MIRROR",i,hdroffset + i*0x8000,(i*0x8000), 0x8000);
for (i = 0; i < ((arch->size - hdroffset) / 0x8000) ; i++) {
// XXX check integer overflow here
addrom (ret, "ROM",i,hdroffset + i * 0x8000, 0x400000 + (i * 0x8000), 0x8000);
if (i % 2) {
addrom(ret, "ROM_MIRROR", i, hdroffset + i * 0x8000,(i * 0x8000), 0x8000);
}
}
} else {
@ -171,7 +172,7 @@ static RList* sections(RBinFile *arch) {
static RList *mem (RBinFile *arch) {
RList *ret;
RBinMem *m, *n;
RBinMem *m;
if (!(ret = r_list_new())) {
return NULL;
}
@ -185,18 +186,18 @@ static RList *mem (RBinFile *arch) {
m->size = LOWRAM_SIZE;
m->perms = r_str_rwx ("rwx");
r_list_append (ret, m);
if (!(n = R_NEW0 (RBinMem))) {
if (!(m = R_NEW0 (RBinMem))) {
return ret;
}
m->mirrors = r_list_new();
n->name = strdup ("LOWRAM_MIRROR");
n->addr = LOWRAM_MIRROR_START_ADDRESS;
n->size = LOWRAM_MIRROR_SIZE;
n->perms = r_str_rwx ("rwx");
r_list_append (m->mirrors, n);
if (!(n = R_NEW0 (RBinMem))) {
m->mirrors = r_list_new ();
m->name = strdup ("LOWRAM_MIRROR");
m->addr = LOWRAM_MIRROR_START_ADDRESS;
m->size = LOWRAM_MIRROR_SIZE;
m->perms = r_str_rwx ("rwx");
r_list_append (m->mirrors, m);
if (!(m = R_NEW0 (RBinMem))) {
r_list_free (m->mirrors);
m->mirrors = NULL;
return ret;
}
m->name = strdup ("HIRAM");
@ -204,7 +205,7 @@ static RList *mem (RBinFile *arch) {
m->size = HIRAM_SIZE;
m->perms = r_str_rwx ("rwx");
r_list_append (ret, m);
if (!(n = R_NEW0 (RBinMem))) {
if (!(m = R_NEW0 (RBinMem))) {
return ret;
}
m->name = strdup ("EXTRAM");
@ -212,7 +213,7 @@ static RList *mem (RBinFile *arch) {
m->size = EXTRAM_SIZE;
m->perms = r_str_rwx ("rwx");
r_list_append (ret, m);
if (!(n = R_NEW0 (RBinMem))) {
if (!(m = R_NEW0 (RBinMem))) {
return ret;
}
m->name = strdup ("PPU1_REG");
@ -247,10 +248,6 @@ static RList *mem (RBinFile *arch) {
m->size = PPU2_REG_SIZE;
m->perms = r_str_rwx ("rwx");
r_list_append (ret, m);
if (!(m = R_NEW0 (RBinMem))) {
r_list_free (ret);
return NULL;
}
return ret;
}

View File

@ -45,8 +45,9 @@ static bool dumpSectionToDisk(RCore *core, char *file) {
ut8 *buf = malloc (s->size);
r_io_read_at (core->io, s->paddr, buf, s->size);
if (!file) {
heapfile = (char *)malloc (len * sizeof(char));
heapfile = (char *)malloc (len);
if (!heapfile) {
free (buf);
return false;
}
file = heapfile;

View File

@ -775,7 +775,7 @@ R_API int r_io_pwrite (RIO *io, ut64 paddr, const ut8 *buf, int len) {
if (!io->desc || !io->desc->plugin || !io->desc->plugin->write) {
return -1;
}
if (r_io_seek (io, paddr, R_IO_SEEK_SET) === UT64_MAX) {
if (r_io_seek (io, paddr, R_IO_SEEK_SET) == UT64_MAX) {
return -1;
}
return io->desc->plugin->write (io, io->desc, buf, len);

View File

@ -232,6 +232,7 @@ static RRunProfile* _get_run_profile(RIO *io, int bits, char **argv) {
if (io->runprofile && *io->runprofile) {
if (!r_run_parsefile (rp, io->runprofile)) {
eprintf ("Can't find profile '%s'\n", io->runprofile);
r_run_free (rp);
return NULL;
}
}
@ -243,6 +244,7 @@ static RRunProfile* _get_run_profile(RIO *io, int bits, char **argv) {
free (expr);
if (r_run_config_env (rp)) {
eprintf ("Can't config the environment.\n");
r_run_free (rp);
return NULL;
}
return rp;

View File

@ -14,10 +14,10 @@ static char *encodings[3] = { "ascii", "cp850", NULL };
R_API int r_search_get_encoding(const char *name) {
int i;
ut32 lename = strlen (name);
if (!name) {
if (!name || !*name) {
return ENCODING_ASCII;
}
ut32 lename = strlen (name);
for (i = 0; encodings[i]; i++) {
ut32 sz = R_MIN (strlen (encodings[i]), lename);
if (!strncasecmp (name, encodings[i], sz)) {