only set outlen on success

This commit is contained in:
Steffen Jaeckel 2017-05-01 21:42:12 +02:00
parent d02531d4d2
commit 31dcb9ff2a

View File

@ -52,14 +52,15 @@ int hash_filehandle(int hash, FILE *in, unsigned char *out, unsigned long *outle
goto LBL_ERR; goto LBL_ERR;
} }
*outlen = hash_descriptor[hash].hashsize;
do { do {
x = fread(buf, 1, LTC_FILE_READ_BUFSIZE, in); x = fread(buf, 1, LTC_FILE_READ_BUFSIZE, in);
if ((err = hash_descriptor[hash].process(&md, buf, (unsigned long)x)) != CRYPT_OK) { if ((err = hash_descriptor[hash].process(&md, buf, (unsigned long)x)) != CRYPT_OK) {
goto LBL_CLEANBUF; goto LBL_CLEANBUF;
} }
} while (x == LTC_FILE_READ_BUFSIZE); } while (x == LTC_FILE_READ_BUFSIZE);
err = hash_descriptor[hash].done(&md, out); if ((err = hash_descriptor[hash].done(&md, out)) == CRYPT_OK) {
*outlen = hash_descriptor[hash].hashsize;
}
LBL_CLEANBUF: LBL_CLEANBUF:
zeromem(buf, LTC_FILE_READ_BUFSIZE); zeromem(buf, LTC_FILE_READ_BUFSIZE);