# HG changeset patch
# User Catalin Patulea <cat@vv.carleton.ca>
# Date 1420152466 18000
#      Thu Jan 01 17:47:46 2015 -0500
# Branch ecdsareadme
# Node ID ea554f473f766974625c32f28e6720d23784c4a1
# Parent  5342b5a69bfdf342f89ee5e3eb26c358669ea821
Handle invalid agent keys by skipping rather than exiting.

My agent exposes both conventional keys and certs (ecdsa-sha2-nistp256-cert-v01@openssh.com) and I want dropbear to be able to use the former.

diff -r 5342b5a69bfd -r ea554f473f76 cli-agentfwd.c
--- a/cli-agentfwd.c	Sun Feb 09 03:56:50 2014 -0500
+++ b/cli-agentfwd.c	Thu Jan 01 17:47:46 2015 -0500
@@ -210,13 +210,14 @@
 		ret = buf_get_pub_key(key_buf, pubkey, &key_type);
 		buf_free(key_buf);
 		if (ret != DROPBEAR_SUCCESS) {
-			/* This is slack, properly would cleanup vars etc */
-			dropbear_exit("Bad pubkey received from agent");
+			TRACE(("Skipping bad pubkey from agent"));
+			sign_key_free(pubkey);
+		} else {
+			pubkey->type = key_type;
+			pubkey->source = SIGNKEY_SOURCE_AGENT;
+
+			list_append(ret_list, pubkey);
 		}
-		pubkey->type = key_type;
-		pubkey->source = SIGNKEY_SOURCE_AGENT;
-
-		list_append(ret_list, pubkey);
 
 		/* We'll ignore the comment for now. might want it later.*/
 		buf_eatstring(inbuf);
