Do not add zignatures with zero mask

Fix #5688
This commit is contained in:
Roi Martin 2017-03-19 17:20:31 +00:00
parent 0bf4aaae1e
commit 0ca78a43e5
4 changed files with 20 additions and 0 deletions

View File

@ -3,6 +3,7 @@
#include <r_anal.h>
#include <r_sign.h>
#include <r_search.h>
#include <r_util.h>
R_LIB_VERSION (r_sign);
@ -139,6 +140,12 @@ static bool addBytes(RAnal *a, int type, const char *name, ut64 size, const ut8
RSignItem *it = R_NEW0 (RSignItem);
bool retval = true;
if (r_mem_is_zero (mask, size)) {
eprintf ("error: zero mask\n");
retval = false;
goto exit_function;
}
it->type = type;
it->name = r_str_new (name);
it->space = a->zign_spaces.space_idx;
@ -150,6 +157,7 @@ static bool addBytes(RAnal *a, int type, const char *name, ut64 size, const ut8
retval = add (a, it);
exit_function:
r_sign_item_free (it);
return retval;

View File

@ -5,6 +5,7 @@
#include <r_sign.h>
#include <r_list.h>
#include <r_cons.h>
#include <r_util.h>
static bool addFcnBytes(RCore *core, RAnalFunction *fcn, int type, int minzlen, int maxzlen) {
int fcnlen = 0, len = 0;

View File

@ -44,4 +44,5 @@ R_API const ut8 *r_mem_mem(const ut8 *haystack, int hlen, const ut8 *needle, int
R_API const ut8 *r_mem_mem_aligned(const ut8 *haystack, int hlen, const ut8 *needle, int nlen, int align);
R_API int r_mem_count(const ut8 **addr);
R_API bool r_mem_is_printable (const ut8 *a, int la);
R_API bool r_mem_is_zero(const ut8 *b, int l);
#endif // R_MEM_H

View File

@ -316,3 +316,13 @@ R_API bool r_mem_is_printable(const ut8 *a, int la) {
}
return true;
}
R_API bool r_mem_is_zero(const ut8 *b, int l) {
int i;
for (i = 0; i < l; i++) {
if (b[i]) {
return false;
}
}
return true;
}