[gnutls-devel] [PATCH 1/2] tpm: must clear pkey each time we go round the import loop

James Bottomley James.Bottomley at HansenPartnership.com
Sat Dec 3 23:32:21 CET 2016


There's a coding bug in the do .. while loop in import_tpm_key_cb() On
entry, the pkey is initialised but blank (meaning set to zero), but as
soon as import_tpm_key() is called, the pkey structure will become
initialised.  This means that the assert of an uninitialised pkey in
gnutls_privkey_import_ext2() fails if we go around the loop again.

Fix this by manually clearing the pkey on each loop.

Signed-off-by: James Bottomley <James.Bottomley at HansenPartnership.com>
---
 lib/tpm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/tpm.c b/lib/tpm.c
index 23e4479..506019e 100644
--- a/lib/tpm.c
+++ b/lib/tpm.c
@@ -458,6 +458,7 @@ import_tpm_key_cb(gnutls_privkey_t pkey, const gnutls_datum_t * fdata,
 	int ret, ret2;
 
 	do {
+		memset(pkey, 0, sizeof(*pkey));
 		ret =
 		    import_tpm_key(pkey, fdata, format, uuid, storage,
 				   srk_password, key_password);
-- 
2.6.6




More information about the Gnutls-devel mailing list