Fix all latest Coverity issues
This commit is contained in:
parent
2352c6a105
commit
b40bce8284
|
@ -104,7 +104,7 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
|
|||
if (insn == NULL)
|
||||
insn = cs_malloc (cd);
|
||||
insn->size = 1;
|
||||
memset (insn, 0, sizeof(cd));
|
||||
memset (insn, 0, cd);
|
||||
n = cs_disasm_iter (cd, (const uint8_t**)&buf, &size, (uint64_t*)&off, insn);
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -547,7 +547,8 @@ static RList* classes (RBinFile *arch) {
|
|||
if (entry.source_file >= bin->size) {
|
||||
continue;
|
||||
}
|
||||
if (entry.source_file<0 || entry.source_file >= bin->header.strings_size)
|
||||
// unsigned if (entry.source_file<0 || entry.source_file >= bin->header.strings_size)
|
||||
if (entry.source_file >= bin->header.strings_size)
|
||||
continue;
|
||||
r_buf_read_at (bin->b, bin->strings[entry.source_file],
|
||||
(ut8*)name, len);
|
||||
|
|
|
@ -43,18 +43,17 @@ static void r_core_file_info (RCore *core, int mode) {
|
|||
} else fn = (cf && cf->desc) ? cf->desc->name : NULL;
|
||||
if (cf && mode == R_CORE_BIN_JSON) {
|
||||
r_cons_printf ("\"file\":\"%s\"", fn);
|
||||
if (cf->desc->referer)
|
||||
r_cons_printf ("\"referer\":\"%s\"", cf->desc->referer);
|
||||
if (dbg) dbg = R_IO_WRITE | R_IO_EXEC;
|
||||
if (cf->desc) {
|
||||
r_cons_printf (",\"uri\":\"%s\"", cf->desc->uri);
|
||||
r_cons_printf (",\"fd\":%d", cf->desc->fd);
|
||||
r_cons_printf (",\"size\":%"PFMT64d, r_io_desc_size (core->io, cf->desc));
|
||||
r_cons_printf (",\"mode\":\"%s\"", r_str_rwx_i (
|
||||
cf->desc->flags & 7 ));
|
||||
if (cf->desc->referer)
|
||||
r_cons_printf ("\"referer\":\"%s\"", cf->desc->referer);
|
||||
}
|
||||
r_cons_printf (",\"block\":%d", core->blocksize);
|
||||
if (cf->desc)
|
||||
r_cons_printf (",\"uri\":\"%s\"", cf->desc->uri);
|
||||
if (binfile) {
|
||||
if (binfile->curxtr)
|
||||
r_cons_printf (",\"packet\":\"%s\"",
|
||||
|
@ -67,17 +66,15 @@ static void r_core_file_info (RCore *core, int mode) {
|
|||
} else if (cf) {
|
||||
//r_cons_printf ("# Core file info\n");
|
||||
r_cons_printf ("file\t%s\n", fn);
|
||||
if (cf->desc->referer)
|
||||
r_cons_printf ("referer\t%s\n", cf->desc->referer);
|
||||
if (dbg) dbg = R_IO_WRITE | R_IO_EXEC;
|
||||
if (cf->desc) {
|
||||
r_cons_printf ("referer\t%s\n", cf->desc->referer);
|
||||
r_cons_printf ("fd\t%d\n", cf->desc->fd);
|
||||
r_cons_printf ("size\t0x%"PFMT64x"\n", r_io_desc_size (core->io, cf->desc));
|
||||
r_cons_printf ("mode\t%s\n", r_str_rwx_i (cf->desc->flags & 7 ));
|
||||
r_cons_printf ("uri\t%s\n", cf->desc->uri);
|
||||
}
|
||||
r_cons_printf ("block\t0x%x\n", core->blocksize);
|
||||
if (cf->desc)
|
||||
r_cons_printf ("uri\t%s\n", cf->desc->uri);
|
||||
if (binfile && binfile->curxtr)
|
||||
r_cons_printf ("packet\t%s\n",
|
||||
binfile->curxtr->name);
|
||||
|
|
|
@ -20,7 +20,7 @@ R_API int r_core_file_reopen(RCore *core, const char *args, int perm, int loadbi
|
|||
RBinFile *bf = (ofile && ofile->desc) ?
|
||||
r_bin_file_find_by_fd (core->bin, ofile->desc->fd) : NULL;
|
||||
RIODesc *odesc = ofile ? ofile->desc : NULL;
|
||||
char *ofilepath, *obinfilepath = bf ? strdup (bf->file) : NULL;
|
||||
char *ofilepath = NULL, *obinfilepath = bf ? strdup (bf->file) : NULL;
|
||||
int newpid, ret = R_FALSE;
|
||||
ut64 origoff = core->offset;
|
||||
if (odesc) {
|
||||
|
@ -657,6 +657,7 @@ R_API RCoreFile *r_core_file_open(RCore *r, const char *file, int flags, ut64 lo
|
|||
fh->map = r_core_file_get_next_map (r, fh, flags, loadaddr);
|
||||
if (!fh->map) {
|
||||
r_core_file_free (fh);
|
||||
free (fh);
|
||||
fh = NULL;
|
||||
if (!strcmp (suppress_warning, "false"))
|
||||
eprintf("Unable to load file due to failed mapping.\n");
|
||||
|
@ -688,8 +689,11 @@ R_API void r_core_file_free(RCoreFile *cf) {
|
|||
RIO *io = NULL;
|
||||
if (cf) {
|
||||
io = (RIO*)(cf->desc ? cf->desc->io : NULL);
|
||||
if (cf->map) {
|
||||
r_io_map_del_all (io, cf->map->fd);
|
||||
cf->map = NULL;
|
||||
}
|
||||
r_bin_file_deref_by_bind (&cf->binb);
|
||||
if (cf->map) r_io_map_del_all (io, cf->map->fd);
|
||||
r_io_close ((RIO *) io, cf->desc);
|
||||
free (cf);
|
||||
}
|
||||
|
|
|
@ -116,11 +116,11 @@ R_API int r_hex_str2bin(const char *in, ut8 *out) {
|
|||
|
||||
if (!in || !*in)
|
||||
return 0;
|
||||
if (!memcmp (in, "0x", 2))
|
||||
if (!strncmp (in, "0x", 2))
|
||||
in += 2;
|
||||
if (!out) {
|
||||
outbuf = 1;
|
||||
out = malloc (strlen (in));
|
||||
out = malloc (strlen (in)+1);
|
||||
}
|
||||
for (ptr = in; ; ptr++) {
|
||||
/* comments */
|
||||
|
|
Loading…
Reference in New Issue