From: Or Ozeri Date: Thu, 8 Apr 2021 17:13:49 +0000 (+0300) Subject: librbd/crypto: fix bad return checks from libcryptsetup X-Git-Tag: v17.1.0~2187^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=c0e6c07ae0349eec048d9222e0495850c7690b73;p=ceph.git librbd/crypto: fix bad return checks from libcryptsetup This commit fixes the return checks for libcryptsetup functions that may return non-zero success codes. Fixes: https://tracker.ceph.com/issues/50461 Signed-off-by: Or Ozeri --- diff --git a/src/librbd/crypto/luks/Header.cc b/src/librbd/crypto/luks/Header.cc index 6d00074efcf80..ee8c8b555240b 100644 --- a/src/librbd/crypto/luks/Header.cc +++ b/src/librbd/crypto/luks/Header.cc @@ -183,7 +183,7 @@ int Header::add_keyslot(const char* passphrase, size_t passphrase_size) { auto r = crypt_keyslot_add_by_volume_key( m_cd, CRYPT_ANY_SLOT, NULL, 0, passphrase, passphrase_size); - if (r != 0) { + if (r < 0) { lderr(m_cct) << "crypt_keyslot_add_by_volume_key failed: " << cpp_strerror(r) << dendl; return r; @@ -222,7 +222,7 @@ int Header::read_volume_key(const char* passphrase, size_t passphrase_size, auto r = crypt_volume_key_get( m_cd, CRYPT_ANY_SLOT, volume_key, volume_key_size, passphrase, passphrase_size); - if (r != 0) { + if (r < 0) { lderr(m_cct) << "crypt_volume_key_get failed: " << cpp_strerror(r) << dendl; return r;