summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2013-03-24 21:06:06 +0100
committerHelmut Grohne <helmut@subdivi.de>2013-03-24 21:06:06 +0100
commitaaa44b3c98db6508886b69c301021c38b3344a8a (patch)
tree65306731df9ba100f76991c3f148f0ccafe0cdb0
parent4e25336922485a918e2f8bf84cd1a82f10c78351 (diff)
downloadssdeep-aaa44b3c98db6508886b69c301021c38b3344a8a.tar.gz
properly set errno
-rw-r--r--fuzzy.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/fuzzy.c b/fuzzy.c
index c82d3c1..a9e6d4a 100644
--- a/fuzzy.c
+++ b/fuzzy.c
@@ -23,6 +23,7 @@
*/
#include <assert.h>
+#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -112,6 +113,7 @@ struct fuzzy_state {
/*@only@*/ /*@null@*/ struct fuzzy_state *fuzzy_new(void) {
struct fuzzy_state *self;
if(NULL == (self = malloc(sizeof(struct fuzzy_state))))
+ /* malloc sets ENOMEM */
return NULL;
self->bhstart = 0;
self->bhend = 1;
@@ -222,9 +224,11 @@ int fuzzy_digest(const struct fuzzy_state *self, /*@out@*/ char *result) {
/* Initial blocksize guess. */
while((size_t)SSDEEP_BS(bi) * SPAMSUM_LENGTH < self->total_size) {
++bi;
- if(bi >= SSDEEP_BS(NUM_BLOCKHASHES))
+ if(bi >= NUM_BLOCKHASHES) {
/* The input exceeds data types. */
+ errno = EOVERFLOW;
return -1;
+ }
}
/* Adapt blocksize guess to actual digest length. */
while(bi >= self->bhend)
@@ -235,6 +239,7 @@ int fuzzy_digest(const struct fuzzy_state *self, /*@out@*/ char *result) {
i = snprintf(result, (size_t)remain, "%u:", SSDEEP_BS(bi));
if(i <= 0)
+ /* Maybe snprintf has set errno here? */
return -1;
assert(i < remain);
remain -= i;