diff options
author | djm@openbsd.org <djm@openbsd.org> | 2016-02-12 01:20:30 +0100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2016-02-12 01:23:05 +0100 |
commit | d2d772f55b19bb0e8d03c2fe1b9bb176d9779efd (patch) | |
tree | 3eaf019f2e9185be99c51760a970a825467dec2c /ssh-pkcs11.c | |
parent | upstream commit (diff) | |
download | openssh-d2d772f55b19bb0e8d03c2fe1b9bb176d9779efd.tar.xz openssh-d2d772f55b19bb0e8d03c2fe1b9bb176d9779efd.zip |
upstream commit
avoid fatal() for PKCS11 tokens that present empty key IDs
bz#1773, ok markus@
Upstream-ID: 044a764fee526f2c4a9d530bd10695422d01fc54
Diffstat (limited to '')
-rw-r--r-- | ssh-pkcs11.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/ssh-pkcs11.c b/ssh-pkcs11.c index 92614a52d..d1f750db0 100644 --- a/ssh-pkcs11.c +++ b/ssh-pkcs11.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-pkcs11.c,v 1.21 2015/07/18 08:02:17 djm Exp $ */ +/* $OpenBSD: ssh-pkcs11.c,v 1.22 2016/02/12 00:20:30 djm Exp $ */ /* * Copyright (c) 2010 Markus Friedl. All rights reserved. * @@ -322,8 +322,10 @@ pkcs11_rsa_wrap(struct pkcs11_provider *provider, CK_ULONG slotidx, k11->slotidx = slotidx; /* identify key object on smartcard */ k11->keyid_len = keyid_attrib->ulValueLen; - k11->keyid = xmalloc(k11->keyid_len); - memcpy(k11->keyid, keyid_attrib->pValue, k11->keyid_len); + if (k11->keyid_len > 0) { + k11->keyid = xmalloc(k11->keyid_len); + memcpy(k11->keyid, keyid_attrib->pValue, k11->keyid_len); + } k11->orig_finish = def->finish; memcpy(&k11->rsa_method, def, sizeof(k11->rsa_method)); k11->rsa_method.name = "pkcs11"; |