kentpeacock / rpms / openssh

Forked from rpms/openssh 2 years ago
Clone
b58e57
diff --git a/ssh-agent.c b/ssh-agent.c
b58e57
index 1320cda..2441329 100644
b58e57
--- a/ssh-agent.c
b58e57
+++ b/ssh-agent.c
b58e57
@@ -821,7 +821,7 @@ send:
b58e57
 static void
b58e57
 process_remove_smartcard_key(SocketEntry *e)
b58e57
 {
b58e57
-	char *provider = NULL, *pin = NULL;
b58e57
+	char *provider = NULL, *pin = NULL, canonical_provider[PATH_MAX];
b58e57
 	int r, version, success = 0;
b58e57
 	Identity *id, *nxt;
b58e57
 	Idtab *tab;
b58e57
@@ -831,6 +831,13 @@ process_remove_smartcard_key(SocketEntry *e)
b58e57
 		fatal("%s: buffer error: %s", __func__, ssh_err(r));
b58e57
 	free(pin);
b58e57
 
b58e57
+	if (realpath(provider, canonical_provider) == NULL) {
b58e57
+		verbose("failed PKCS#11 add of \"%.100s\": realpath: %s",
b58e57
+		    provider, strerror(errno));
b58e57
+		goto send;
b58e57
+	}
b58e57
+
b58e57
+	debug("%s: remove %.100s", __func__, canonical_provider);
b58e57
 	for (version = 1; version < 3; version++) {
b58e57
 		tab = idtab_lookup(version);
b58e57
 		for (id = TAILQ_FIRST(&tab->idlist); id; id = nxt) {
b58e57
@@ -838,18 +845,19 @@ process_remove_smartcard_key(SocketEntry *e)
b58e57
 			/* Skip file--based keys */
b58e57
 			if (id->provider == NULL)
b58e57
 				continue;
b58e57
-			if (!strcmp(provider, id->provider)) {
b58e57
+			if (!strcmp(canonical_provider, id->provider)) {
b58e57
 				TAILQ_REMOVE(&tab->idlist, id, next);
b58e57
 				free_identity(id);
b58e57
 				tab->nentries--;
b58e57
 			}
b58e57
 		}
b58e57
 	}
b58e57
-	if (pkcs11_del_provider(provider) == 0)
b58e57
+	if (pkcs11_del_provider(canonical_provider) == 0)
b58e57
 		success = 1;
b58e57
 	else
b58e57
 		error("process_remove_smartcard_key:"
b58e57
 		    " pkcs11_del_provider failed");
b58e57
+send:
b58e57
 	free(provider);
b58e57
 	send_status(e, success);
b58e57
 }
b58e57