From 27eaf46c8a4e512588792725a2a27afd4648700d Mon Sep 17 00:00:00 2001
From: Milan Broz <gmazyland@gmail.com>
Date: Sun, 14 Oct 2018 21:47:11 +0200
Subject: [PATCH 077/324] Fix issues found by Coverity scan.

- possible overflow of data offset calculation in wipe and
- dereferencing of pointer in a keyring error path.
---
 lib/luks1/keymanage.c | 2 +-
 lib/utils_keyring.c   | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/utils_keyring.c b/lib/utils_keyring.c
index 2631405..35bf32b 100644
--- a/lib/utils_keyring.c
+++ b/lib/utils_keyring.c
@@ -133,7 +133,8 @@ int keyring_get_passphrase(const char *key_desc,
 
 	if (ret < 0) {
 		err = errno;
-		crypt_memzero(buf, len);
+		if (buf)
+			crypt_memzero(buf, len);
 		free(buf);
 		return -err;
 	}
-- 
2.19.1

