From b81cb74923ce43846bb1ce35b959218b39a50a9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Felipe=20Melchor?= Date: Sat, 17 Oct 2015 17:33:17 +0200 Subject: [PATCH] Fix rabin2 test --- libr/hash/calc.c | 5 +++-- libr/hash/hash.c | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libr/hash/calc.c b/libr/hash/calc.c index c9e151ca69..bad3c77b8a 100644 --- a/libr/hash/calc.c +++ b/libr/hash/calc.c @@ -4,8 +4,9 @@ /* TODO: do it more beautiful with structs and not spaguetis */ R_API int r_hash_calculate(RHash *ctx, ut64 algobit, const ut8 *buf, int len) { - if (len <= 0) - return 0; + + if (len < 0) return 0; + if (len == 0) return r_hash_size (algobit); if (algobit & R_HASH_MD4) { r_hash_do_md4 (ctx, buf, len); return R_HASH_SIZE_MD4; diff --git a/libr/hash/hash.c b/libr/hash/hash.c index 66ce10b45e..36efd062bf 100644 --- a/libr/hash/hash.c +++ b/libr/hash/hash.c @@ -171,8 +171,7 @@ R_API char *r_hash_to_string(RHash *ctx, const char *name, const ut8 *data, int char *digest_hex = NULL; RHash *myctx = NULL; int i, digest_size; - - if (!algo || !name || !data || len < 0) { + if (!algo || !data) { return NULL; } if (!ctx) {