summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2015-07-18 08:02:17 +0000
committerdjm <djm@openbsd.org>2015-07-18 08:02:17 +0000
commit71eb7f6d7d3b6e1536b355f5d808d7d748af7370 (patch)
treec6cb156235a69f746c6a600eb72491e1d2d30a1b
parentskip uninitialised PKCS#11 slots; patch from Jakub Jelen in bz#2427 (diff)
downloadwireguard-openbsd-71eb7f6d7d3b6e1536b355f5d808d7d748af7370.tar.xz
wireguard-openbsd-71eb7f6d7d3b6e1536b355f5d808d7d748af7370.zip
don't ignore PKCS#11 hosted keys that return empty CKA_ID;
patch by Jakub Jelen via bz#2429; ok markus
-rw-r--r--usr.bin/ssh/ssh-pkcs11.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/usr.bin/ssh/ssh-pkcs11.c b/usr.bin/ssh/ssh-pkcs11.c
index 1e4c145f799..7af883f0ad5 100644
--- a/usr.bin/ssh/ssh-pkcs11.c
+++ b/usr.bin/ssh/ssh-pkcs11.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-pkcs11.c,v 1.20 2015/07/18 08:00:21 djm Exp $ */
+/* $OpenBSD: ssh-pkcs11.c,v 1.21 2015/07/18 08:02:17 djm Exp $ */
/*
* Copyright (c) 2010 Markus Friedl. All rights reserved.
*
@@ -470,15 +470,23 @@ pkcs11_fetch_keys_filter(struct pkcs11_provider *p, CK_ULONG slotidx,
error("C_GetAttributeValue failed: %lu", rv);
continue;
}
- /* check that none of the attributes are zero length */
- if (attribs[0].ulValueLen == 0 ||
- attribs[1].ulValueLen == 0 ||
+ /*
+ * Allow CKA_ID (always first attribute) to be empty, but
+ * ensure that none of the others are zero length.
+ * XXX assumes CKA_ID is always first.
+ */
+ if (attribs[1].ulValueLen == 0 ||
attribs[2].ulValueLen == 0) {
continue;
}
/* allocate buffers for attributes */
- for (i = 0; i < 3; i++)
- attribs[i].pValue = xmalloc(attribs[i].ulValueLen);
+ for (i = 0; i < 3; i++) {
+ if (attribs[i].ulValueLen > 0) {
+ attribs[i].pValue = xmalloc(
+ attribs[i].ulValueLen);
+ }
+ }
+
/*
* retrieve ID, modulus and public exponent of RSA key,
* or ID, subject and value for certificates.