Skip to content

Commit

Permalink
Fix undefined behaviour introduced after fix in regression
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Apr 18, 2017
1 parent 3bb3d6a commit 4b77cb2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions binr/radiff2/radiff2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions libr/anal/diff.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2010-2016 - nibble, pancake */
/* radare - LGPL - Copyright 2010-2017 - nibble, pancake */

#include <r_anal.h>
#include <r_util.h>
Expand Down Expand Up @@ -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))) {
Expand Down

0 comments on commit 4b77cb2

Please sign in to comment.