comparison libtomcrypt/src/hashes/helper/hash_filehandle.c @ 1733:d529a52b2f7c coverity coverity

merge coverity from main
author Matt Johnston <matt@ucc.asn.au>
date Fri, 26 Jun 2020 21:07:34 +0800
parents 1ff2a1034c52
children
comparison
equal deleted inserted replaced
1643:b59623a64678 1733:d529a52b2f7c
12 /** 12 /**
13 @file hash_filehandle.c 13 @file hash_filehandle.c
14 Hash open files, Tom St Denis 14 Hash open files, Tom St Denis
15 */ 15 */
16 16
17 /** 17 /**
18 Hash data from an open file handle. 18 Hash data from an open file handle.
19 @param hash The index of the hash you want to use 19 @param hash The index of the hash you want to use
20 @param in The FILE* handle of the file you want to hash 20 @param in The FILE* handle of the file you want to hash
21 @param out [out] The destination of the digest 21 @param out [out] The destination of the digest
22 @param outlen [in/out] The max size and resulting size of the digest 22 @param outlen [in/out] The max size and resulting size of the digest
23 @result CRYPT_OK if successful 23 @result CRYPT_OK if successful
24 */ 24 */
25 int hash_filehandle(int hash, FILE *in, unsigned char *out, unsigned long *outlen) 25 int hash_filehandle(int hash, FILE *in, unsigned char *out, unsigned long *outlen)
26 { 26 {
27 hash_state md; 27 hash_state md;
28 unsigned char *buf; 28 unsigned char *buf;
55 if ((err = hash_descriptor[hash].process(&md, buf, (unsigned long)x)) != CRYPT_OK) { 55 if ((err = hash_descriptor[hash].process(&md, buf, (unsigned long)x)) != CRYPT_OK) {
56 goto LBL_CLEANBUF; 56 goto LBL_CLEANBUF;
57 } 57 }
58 } while (x == LTC_FILE_READ_BUFSIZE); 58 } while (x == LTC_FILE_READ_BUFSIZE);
59 if ((err = hash_descriptor[hash].done(&md, out)) == CRYPT_OK) { 59 if ((err = hash_descriptor[hash].done(&md, out)) == CRYPT_OK) {
60 *outlen = hash_descriptor[hash].hashsize; 60 *outlen = hash_descriptor[hash].hashsize;
61 } 61 }
62 62
63 LBL_CLEANBUF: 63 LBL_CLEANBUF:
64 zeromem(buf, LTC_FILE_READ_BUFSIZE); 64 zeromem(buf, LTC_FILE_READ_BUFSIZE);
65 LBL_ERR: 65 LBL_ERR:
66 XFREE(buf); 66 XFREE(buf);