diff options
Diffstat (limited to 'fuzzy.c')
-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; |