From 4b77cb2c36f8c99d09d14ee411e9c5c14b55c609 Mon Sep 17 00:00:00 2001 From: pancake Date: Tue, 18 Apr 2017 17:22:32 +0200 Subject: [PATCH] Fix undefined behaviour introduced after fix in regression --- binr/radiff2/radiff2.c | 6 +++--- libr/anal/diff.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/binr/radiff2/radiff2.c b/binr/radiff2/radiff2.c index a9b64de8ce2b8..67988e4f25c66 100644 --- a/binr/radiff2/radiff2.c +++ b/binr/radiff2/radiff2.c @@ -86,7 +86,7 @@ static void readstr(char *s, int sz, const ut8 *buf, int len) { static int cb(RDiff *d, void *user, RDiffOp *op) { int i; // , diffmode = (int)(size_t)user; - char s[256]; + char s[256] = {0}; if (showcount) { count++; return 1; @@ -378,7 +378,7 @@ static ut8 *slurp(RCore **c, const char *file, int *sz) { return NULL; } size = r_io_size (io); - if (size > 0 || size < ST32_MAX) { + if (size > 0 && size < ST32_MAX) { data = calloc (1, size); if (r_io_read_at (io, 0, data, size) == size) { if (sz) { @@ -389,7 +389,7 @@ static ut8 *slurp(RCore **c, const char *file, int *sz) { R_FREE (data); } } else { - eprintf ("slurp: File is too big\n"); + eprintf ("slurp: Invalid file size\n"); } r_io_close (io, d); return data; diff --git a/libr/anal/diff.c b/libr/anal/diff.c index f4083ed294123..62f3d5d1dcf73 100644 --- a/libr/anal/diff.c +++ b/libr/anal/diff.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2010-2016 - nibble, pancake */ +/* radare - LGPL - Copyright 2010-2017 - nibble, pancake */ #include #include @@ -54,7 +54,7 @@ R_API int r_anal_diff_fingerprint_bb(RAnal *anal, RAnalBlock *bb) { if (anal->cur && anal->cur->fingerprint_bb) { return (anal->cur->fingerprint_bb (anal, bb)); } - if (!(bb->fingerprint = malloc (1+bb->size))) { + if (!(bb->fingerprint = malloc (1 + bb->size))) { return false; } if (!(buf = malloc (bb->size + 1))) {