ssh-keyscan for ssh2 (was Re: openssh-2.9p1)

Wayne Davison wayne at blorf.net
Sat May 19 06:25:05 EST 2001


On Fri, 18 May 2001 mouring at etoh.eviladmin.org wrote:
> Ok.. Then DSA is missing and your function is misnamed.
> Remember we have RSA v1, RSA v2, and DSA v2 keys.

I didn't realize that when I named the functions, but I do now.  The
following patch changes the function names, adds the xfree(c->c_kex)
suggestion, and paranoidly sets datafellows to zero if the sscanf()
fails (for some oddball reason).

I'm unsure what you mean by "Then DSA is missing", though.  If there is
still a problem here, let me know.

> But it seems to work nicely.

Cool.  I hope you find it useful.

..wayne..

---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: ssh-keyscan.c
--- old/ssh-keyscan.c	Fri May 18 13:15:26 2001
+++ ./ssh-keyscan.c	Fri May 18 13:17:03 2001
@@ -279,7 +279,7 @@
 }

 Key *
-keygrab_rsa(con *c)
+keygrab_ssh1(con *c)
 {
 	static Key *rsa;
 	static Buffer msg;
@@ -319,7 +319,7 @@
 }

 Key *
-keygrab_dsa(con *c)
+keygrab_ssh2(con *c)
 {
 	Key *key;

@@ -333,6 +333,8 @@
 		fprintf(stderr, "Impossible! dispatch_run() returned!\n");
 		exit(1);
 	}
+	xfree(c->c_kex);
+	c->c_kex = NULL;
 	packet_close();

 	return (key);
@@ -499,6 +501,8 @@

 		if (sscanf(buf, "SSH-%*d.%*d-%[^\n]\n", remote_version) == 1)
 			compat_datafellows(remote_version);
+		else
+			datafellows = 0;
 	}
 	n = snprintf(buf, sizeof buf, "SSH-%d.%d-OpenSSH-keyscan\r\n",
 	    c->c_keytypes & 1 ? PROTOCOL_MAJOR_1 : PROTOCOL_MAJOR_2,
@@ -509,7 +513,7 @@
 		return;
 	}
 	if (!(c->c_keytypes & 1)) {
-		keyprint(c, keygrab_dsa(c));
+		keyprint(c, keygrab_ssh2(c));
 		c->c_keytypes &= ~2;
 		confree(s);
 		return;
@@ -546,7 +550,7 @@
 			c->c_status = CS_KEYS;
 			break;
 		case CS_KEYS:
-			keyprint(c, keygrab_rsa(c));
+			keyprint(c, keygrab_ssh1(c));
 			c->c_keytypes &= ~1;

 			if (c->c_keytypes)
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---




More information about the openssh-unix-dev mailing list