bmh10 / rpms / openssh

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