gcrypt: do not ignore return values
Check the return code from gcrypt's functions. In some cases just log, as it shoulnd't really happen. Fixes various Coverity issues: CID #1444702 CID #1444704 CID #1444706 CID #1444711 CID #1444712 CID #1444713
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
a59eb7d78f
commit
248b1e0aa4
@@ -20,6 +20,7 @@ void initialize_libgcrypt(bool secmem) {
|
||||
|
||||
int string_hashsum(const char *s, size_t len, int md_algorithm, char **out) {
|
||||
_cleanup_(gcry_md_closep) gcry_md_hd_t md = NULL;
|
||||
gcry_error_t err;
|
||||
size_t hash_size;
|
||||
void *hash;
|
||||
char *enc;
|
||||
@@ -29,8 +30,8 @@ int string_hashsum(const char *s, size_t len, int md_algorithm, char **out) {
|
||||
hash_size = gcry_md_get_algo_dlen(md_algorithm);
|
||||
assert(hash_size > 0);
|
||||
|
||||
gcry_md_open(&md, md_algorithm, 0);
|
||||
if (!md)
|
||||
err = gcry_md_open(&md, md_algorithm, 0);
|
||||
if (gcry_err_code(err) != GPG_ERR_NO_ERROR || !md)
|
||||
return -EIO;
|
||||
|
||||
gcry_md_write(md, s, len);
|
||||
|
||||
Reference in New Issue
Block a user