Do not segfault when multiple pkcs11 providers is specified

This commit is contained in:
Jakub Jelen 2019-03-11 16:05:49 +01:00
parent 3339efd12d
commit c694548168

View File

@ -3989,7 +3989,7 @@ diff -up openssh/ssh-pkcs11.c.pkcs11-uri openssh/ssh-pkcs11.c
free(attribs[i].pValue); free(attribs[i].pValue);
} }
if ((rv = f->C_FindObjectsFinal(session)) != CKR_OK) if ((rv = f->C_FindObjectsFinal(session)) != CKR_OK)
@@ -592,126 +750,239 @@ pkcs11_fetch_keys_filter(struct pkcs11_p @@ -592,126 +750,240 @@ pkcs11_fetch_keys_filter(struct pkcs11_p
int int
pkcs11_add_provider(char *provider_id, char *pin, struct sshkey ***keyp) pkcs11_add_provider(char *provider_id, char *pin, struct sshkey ***keyp)
{ {
@ -4276,6 +4276,7 @@ diff -up openssh/ssh-pkcs11.c.pkcs11-uri openssh/ssh-pkcs11.c
- free(p->slotlist); - free(p->slotlist);
- free(p->slotinfo); - free(p->slotinfo);
- free(p); - free(p);
+ TAILQ_REMOVE(&pkcs11_providers, p, next);
+ pkcs11_provider_unref(p); + pkcs11_provider_unref(p);
} }
- if (handle) - if (handle)