diff options
author | Stefan Metzmacher <metze@samba.org> | 2022-02-02 11:07:23 +0100 |
---|---|---|
committer | A Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org> | 2022-02-02 14:39:29 +0000 |
commit | d848127c6ecba6023a48b2645d63c58c02ccb8c4 (patch) | |
tree | d2dee4ab876072557e00acf062e84a64f042c88e | |
parent | cfe93f8001e2b9d4c031a20a2a94446aea79c102 (diff) |
packet-smb2: use better error checking logic in do_decrypt
This hopefully avoids the warnings discussed in
https://gitlab.com/wireshark/wireshark/-/merge_requests/3671
Signed-off-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r-- | epan/dissectors/packet-smb2.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/epan/dissectors/packet-smb2.c b/epan/dissectors/packet-smb2.c index 26f42008ab..2213a374bc 100644 --- a/epan/dissectors/packet-smb2.c +++ b/epan/dissectors/packet-smb2.c @@ -10162,20 +10162,23 @@ do_decrypt(guint8 *data, } /* Open the cipher */ - if ((err = gcry_cipher_open(&cipher_hd, algo, mode, 0))) { + err = gcry_cipher_open(&cipher_hd, algo, mode, 0); + if (err != GPG_ERR_NO_ERROR) { DEBUG("GCRY: open %s/%s", gcry_strsource(err), gcry_strerror(err)); return FALSE; } /* Set the key */ - if ((err = gcry_cipher_setkey(cipher_hd, key, keylen))) { + err = gcry_cipher_setkey(cipher_hd, key, keylen); + if (err != GPG_ERR_NO_ERROR) { DEBUG("GCRY: setkey %s/%s", gcry_strsource(err), gcry_strerror(err)); gcry_cipher_close(cipher_hd); return FALSE; } /* Set the initial value */ - if ((err = gcry_cipher_setiv(cipher_hd, nonce, iv_size))) { + err = gcry_cipher_setiv(cipher_hd, nonce, iv_size); + if (err != GPG_ERR_NO_ERROR) { DEBUG("GCRY: setiv %s/%s", gcry_strsource(err), gcry_strerror(err)); gcry_cipher_close(cipher_hd); return FALSE; @@ -10186,20 +10189,23 @@ do_decrypt(guint8 *data, lengths[2] = 16; /* tag length (signature size) */ if (mode == GCRY_CIPHER_MODE_CCM) { - if ((err = gcry_cipher_ctl(cipher_hd, GCRYCTL_SET_CCM_LENGTHS, lengths, sizeof(lengths)))) { + err = gcry_cipher_ctl(cipher_hd, GCRYCTL_SET_CCM_LENGTHS, lengths, sizeof(lengths)); + if (err != GPG_ERR_NO_ERROR) { DEBUG("GCRY: ctl %s/%s", gcry_strsource(err), gcry_strerror(err)); gcry_cipher_close(cipher_hd); return FALSE; } } - if ((err = gcry_cipher_authenticate(cipher_hd, aad, aad_size))) { + err = gcry_cipher_authenticate(cipher_hd, aad, aad_size); + if (err != GPG_ERR_NO_ERROR) { DEBUG("GCRY: auth %s/%s", gcry_strsource(err), gcry_strerror(err)); gcry_cipher_close(cipher_hd); return FALSE; } - if ((err = gcry_cipher_decrypt(cipher_hd, data, data_size, NULL, 0))) { + err = gcry_cipher_decrypt(cipher_hd, data, data_size, NULL, 0); + if (err != GPG_ERR_NO_ERROR) { DEBUG("GCRY: decrypt %s/%s", gcry_strsource(err), gcry_strerror(err)); gcry_cipher_close(cipher_hd); return FALSE; |