Fix all the coverities detected last month (#17060)
* Fix all the coverities detected last month * Fix one more cov * Fix build * refix build Co-authored-by: pancake <pancake@nopcode.org>
This commit is contained in:
parent
ddeb513374
commit
84ecf9fff2
12 changed files with 35 additions and 26 deletions
|
|
@ -892,6 +892,7 @@ static void replace_cmd_kv_file(const char *path, ut64 line_begin, ut64 line_end
|
|||
} else {
|
||||
eprintf ("Failed to write file \"%s\"\n", path);
|
||||
}
|
||||
free (newc);
|
||||
}
|
||||
|
||||
static void interact_fix(R2RTestResultInfo *result, RPVector *fixup_results) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
/* radare - LGPL - Copyright 2009-2019 - pancake, nibble */
|
||||
/* radare - LGPL - Copyright 2009-2020 - pancake, nibble */
|
||||
|
||||
#include <r_anal.h>
|
||||
#include <r_sign.h>
|
||||
#include <r_search.h>
|
||||
#include <r_util.h>
|
||||
#include <r_core.h>
|
||||
#include <r_hash.h>
|
||||
|
||||
R_LIB_VERSION (r_sign);
|
||||
|
||||
|
|
@ -1092,7 +1090,7 @@ typedef struct {
|
|||
double infimum;
|
||||
} ClosestMatchData;
|
||||
|
||||
static int closest_match_callback(void *a, const char *name, const char *value) {
|
||||
static bool closest_match_callback(void *a, const char *name, const char *value) {
|
||||
ClosestMatchData *data = (ClosestMatchData *)a;
|
||||
|
||||
// get signature in usable format
|
||||
|
|
@ -1205,6 +1203,7 @@ R_API bool r_sign_diff(RAnal *a, RSignOptions *options, const char *other_space_
|
|||
}
|
||||
RList *lb = deserialize_sign_space (a, other_space);
|
||||
if (!lb) {
|
||||
r_list_free (la);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* radare - LGPL - Copyright 2010-2019 - pancake, oddcoder */
|
||||
/* radare - LGPL - Copyright 2010-2020 - pancake, oddcoder */
|
||||
|
||||
#include <r_anal.h>
|
||||
#include <r_util.h>
|
||||
|
|
@ -554,6 +554,7 @@ static char *get_varname(RAnalFunction *fcn, char kind, const char *pfx, int ptr
|
|||
if (!strcmp (varname, var->name)) {
|
||||
if (var->kind != kind) {
|
||||
const char *k = kind == R_ANAL_VAR_KIND_SPV ? "sp" : "bp";
|
||||
free (varname);
|
||||
varname = r_str_newf ("%s_%s_%xh", pfx, k, uptr);
|
||||
return varname;
|
||||
}
|
||||
|
|
@ -729,12 +730,9 @@ static void extract_arg(RAnal *anal, RAnalFunction *fcn, RAnalOp *op, const char
|
|||
r_anal_var_set_access (var, reg, op->addr, rw, -ptr);
|
||||
goto beach;
|
||||
}
|
||||
char *varname;
|
||||
if (anal->opt.varname_stack) {
|
||||
varname = r_str_newf ("%s_%xh", VARPREFIX, R_ABS (frame_off));
|
||||
} else {
|
||||
varname = get_varname (fcn, type, VARPREFIX, -ptr);
|
||||
}
|
||||
char *varname = anal->opt.varname_stack
|
||||
? r_str_newf ("%s_%xh", VARPREFIX, R_ABS (frame_off))
|
||||
: get_varname (fcn, type, VARPREFIX, -ptr);
|
||||
if (varname) {
|
||||
RAnalVar *var = r_anal_function_set_var (fcn, frame_off, type, NULL, anal->bits / 8, false, varname);
|
||||
if (var) {
|
||||
|
|
@ -890,7 +888,7 @@ R_API void r_anal_extract_rarg(RAnal *anal, RAnalOp *op, RAnalFunction *fcn, int
|
|||
}
|
||||
}
|
||||
if (!vname) {
|
||||
name = r_str_newf ("arg%d", i + 1);
|
||||
name = r_str_newf ("arg%lu", i + 1);
|
||||
vname = name;
|
||||
}
|
||||
r_anal_function_set_var (fcn, delta, R_ANAL_VAR_KIND_REG, type, size, true, vname);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* radare - LGPL - Copyright 2017-2019 - pancake, cgvwzq */
|
||||
/* radare - LGPL - Copyright 2017-2020 - pancake, cgvwzq */
|
||||
|
||||
// http://webassembly.org/docs/binary-encoding/#module-structure
|
||||
|
||||
|
|
|
|||
|
|
@ -1634,6 +1634,7 @@ static ut64 get_import_addr(ELFOBJ *bin, int sym) {
|
|||
}
|
||||
|
||||
int Elf_(r_bin_elf_has_nx)(ELFOBJ *bin) {
|
||||
r_return_val_if_fail (bin, 0);
|
||||
int i;
|
||||
if (bin && bin->phdr) {
|
||||
for (i = 0; i < bin->ehdr.e_phnum; i++) {
|
||||
|
|
@ -1646,6 +1647,7 @@ int Elf_(r_bin_elf_has_nx)(ELFOBJ *bin) {
|
|||
}
|
||||
|
||||
int Elf_(r_bin_elf_has_relro)(ELFOBJ *bin) {
|
||||
r_return_val_if_fail (bin, R_ELF_NO_RELRO);
|
||||
int i;
|
||||
bool haveBindNow = false;
|
||||
bool haveGnuRelro = false;
|
||||
|
|
@ -1656,7 +1658,7 @@ int Elf_(r_bin_elf_has_relro)(ELFOBJ *bin) {
|
|||
haveBindNow = bin->dyn_info.dt_flags_1 & DF_1_NOW;
|
||||
}
|
||||
|
||||
if (bin && bin->phdr) {
|
||||
if (bin->phdr) {
|
||||
for (i = 0; i < bin->ehdr.e_phnum; i++) {
|
||||
if (bin->phdr[i].p_type == PT_GNU_RELRO) {
|
||||
haveGnuRelro = true;
|
||||
|
|
|
|||
|
|
@ -1601,8 +1601,13 @@ static bool reconstruct_chained_fixup(struct MACH0_(obj_t) *bin) {
|
|||
}
|
||||
}
|
||||
}
|
||||
ut32 page_index = (ut32)(seg_off / ps);
|
||||
cur_seg->page_start[page_index] = seg_off & 0xfff;
|
||||
if (cur_seg) {
|
||||
ut32 page_index = (ut32)(seg_off / ps);
|
||||
size_t maxsize = cur_seg->page_count * sizeof (ut16);
|
||||
if (page_index < maxsize) {
|
||||
cur_seg->page_start[page_index] = seg_off & 0xfff;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* radare - LGPL3 - Copyright 2016 - Matthieu (c0riolis) Tardy - l0stb1t*/
|
||||
/* radare - LGPL3 - Copyright 2016-2020 - Matthieu (c0riolis) Tardy - l0stb1t*/
|
||||
|
||||
#include <r_io.h>
|
||||
#include <r_bin.h>
|
||||
|
|
@ -1159,7 +1159,7 @@ static bool extract_sections_symbols(pyc_object *obj, RList *sections, RList *sy
|
|||
section = R_NEW0 (RBinSection);
|
||||
symbol = R_NEW0 (RBinSymbol);
|
||||
prefix = r_str_newf ("%s%s%s", prefix? prefix: "",
|
||||
prefix? ".": "", cobj->name->data);
|
||||
prefix? ".": "", (const char *)cobj->name->data);
|
||||
if (!prefix || !section || !symbol) {
|
||||
goto fail;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ static int download(struct SPDBDownloader *pd) {
|
|||
}
|
||||
free (archive_name);
|
||||
free (abspath_to_archive);
|
||||
free (extractor_cmd);
|
||||
}
|
||||
if (res == 0) {
|
||||
eprintf ("Falling back to uncompressed pdb\n");
|
||||
|
|
|
|||
|
|
@ -801,7 +801,8 @@ R_API void r_core_anal_type_match(RCore *core, RAnalFunction *fcn) {
|
|||
RList *list2 = r_anal_var_list (anal, fcn, R_ANAL_VAR_KIND_BPV);
|
||||
r_list_foreach (list2, iter2, bp_var) {
|
||||
if (bp_var->isarg) {
|
||||
const char *query = sdb_fmt ("fcn.0x%08" PFMT64x ".arg.%d", fcn->addr, (bp_var->delta + fcn->bp_off - 8));
|
||||
const char *query = sdb_fmt ("fcn.0x%08" PFMT64x ".arg.%d",
|
||||
fcn->addr, (int)(bp_var->delta + fcn->bp_off - 8));
|
||||
char *type = (char *)sdb_const_get (anal->sdb_fcns, query, NULL);
|
||||
if (type) {
|
||||
__var_retype (anal, bp_var, NULL, type, false, false);
|
||||
|
|
|
|||
|
|
@ -405,8 +405,11 @@ R_API int r_main_radare2(int argc, const char **argv) {
|
|||
LISTS_FREE ();
|
||||
return main_help (1);
|
||||
}
|
||||
// r_core_init (r); // TODO: use r_core_new() for simplicity
|
||||
r = r_core_new ();
|
||||
if (!r) {
|
||||
eprintf ("Cannot initialize RCore\n");
|
||||
return 1;
|
||||
}
|
||||
r->r_main_radare2 = r_main_radare2;
|
||||
r->r_main_radiff2 = r_main_radiff2;
|
||||
r->r_main_rafind2 = r_main_rafind2;
|
||||
|
|
|
|||
|
|
@ -139,11 +139,6 @@ R_API int r_main_rasign2(int argc, const char **argv) {
|
|||
r_config_set_i (core->config, "scr.color", COLOR_MODE_DISABLED);
|
||||
}
|
||||
|
||||
// dump flirt
|
||||
if (flirt) {
|
||||
r_core_cmdf (core, "\"zfd %s\"", ifile);
|
||||
}
|
||||
|
||||
// run analysis to find functions
|
||||
find_functions (core, a_cnt);
|
||||
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ static char *socket_http_get_recursive(const char *url, int *code, int *rlen, ut
|
|||
return http_get_w32 (url, code, rlen);
|
||||
#else
|
||||
RSocket *s;
|
||||
int ssl = r_str_startswith (url, "https://");
|
||||
bool ssl = r_str_startswith (url, "https://");
|
||||
#if !HAVE_LIB_SSL
|
||||
if (ssl) {
|
||||
eprintf ("Tried to get '%s', but SSL support is disabled, set R2_CURL=1 to use curl\n", url);
|
||||
|
|
@ -232,7 +232,11 @@ static char *socket_http_get_recursive(const char *url, int *code, int *rlen, ut
|
|||
host += 3;
|
||||
port = strchr (host, ':');
|
||||
if (!port) {
|
||||
#if HAVE_LIB_SSL
|
||||
port = ssl? "443": "80";
|
||||
#else
|
||||
port = "80";
|
||||
#endif
|
||||
path = host;
|
||||
} else {
|
||||
*port++ = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue