diff svr-kex.c @ 852:7540c0822374 ecc

Various cleanups and fixes for warnings
author Matt Johnston <matt@ucc.asn.au>
date Tue, 12 Nov 2013 23:02:32 +0800
parents 7507b174bba0
children 220f55d540ae
line wrap: on
line diff
--- a/svr-kex.c	Sat Nov 09 00:14:28 2013 +0800
+++ b/svr-kex.c	Tue Nov 12 23:02:32 2013 +0800
@@ -64,18 +64,19 @@
 		case DROPBEAR_KEX_CURVE25519:
 #if defined(DROPBEAR_ECDH) || defined(DROPBEAR_CURVE25519)
 			ecdh_qs = buf_getstringbuf(ses.payload);
-			if (ses.payload->pos != ses.payload->len) {
-				dropbear_exit("Bad kex value");
-			}
 #endif
 			break;
 	}
+	if (ses.payload->pos != ses.payload->len) {
+		dropbear_exit("Bad kex value");
+	}
 
 	send_msg_kexdh_reply(&dh_e, ecdh_qs);
 
 	mp_clear(&dh_e);
 	if (ecdh_qs) {
 		buf_free(ecdh_qs);
+		ecdh_qs = NULL;
 	}
 
 	send_msg_newkeys();
@@ -132,8 +133,11 @@
 	}
 
 	if (link(fn_temp, fn) < 0) {
+		/* It's OK to get EEXIST - we probably just lost a race
+		with another connection to generate the key */
 		if (errno != EEXIST) {
-			dropbear_log(LOG_ERR, "Failed moving key file to %s", fn);
+			dropbear_log(LOG_ERR, "Failed moving key file to %s: %s", fn,
+				strerror(errno));
 			/* XXX fallback to non-atomic copy for some filesystems? */
 			goto out;
 		}
@@ -151,14 +155,6 @@
 	{
 		dropbear_exit("Couldn't read or generate hostkey %s", fn);
 	}
-
-	// directory for keys.
-
-	// Create lockfile first, or wait if it exists. PID!
-	// Generate key
-	// write it, load to memory
-	// atomic rename, done.
-
 }
 #endif