diff options
author | Helmut Grohne <helmut@subdivi.de> | 2013-03-24 21:06:06 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2013-03-24 21:06:06 +0100 |
commit | aaa44b3c98db6508886b69c301021c38b3344a8a (patch) | |
tree | 65306731df9ba100f76991c3f148f0ccafe0cdb0 | |
parent | 4e25336922485a918e2f8bf84cd1a82f10c78351 (diff) | |
download | ssdeep-aaa44b3c98db6508886b69c301021c38b3344a8a.tar.gz |
properly set errno
-rw-r--r-- | fuzzy.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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; |