diff dss.c @ 1413:79582b52a791 fuzz

check p and q lengths
author Matt Johnston <matt@ucc.asn.au>
date Fri, 16 Jun 2017 22:35:18 +0800
parents 771e4a7051e0
children 2d937dc44851
line wrap: on
line diff
--- a/dss.c	Wed Jun 14 23:31:42 2017 +0800
+++ b/dss.c	Fri Jun 16 22:35:18 2017 +0800
@@ -61,8 +61,15 @@
 		goto out;
 	}
 
-	if (mp_count_bits(key->p) < MIN_DSS_KEYLEN) {
-		dropbear_log(LOG_WARNING, "DSS key too short");
+	if (mp_count_bits(key->p) < DSS_P_BITS) {
+		dropbear_log(LOG_WARNING, "Bad DSS p");
+		TRACE(("leave buf_get_dss_pub_key: short key"))
+		ret = DROPBEAR_FAILURE;
+		goto out;
+	}
+
+	if (mp_count_bits(key->q) < DSS_Q_BITS) {
+		dropbear_log(LOG_WARNING, "Bad DSS q");
 		TRACE(("leave buf_get_dss_pub_key: short key"))
 		ret = DROPBEAR_FAILURE;
 		goto out;
@@ -94,7 +101,7 @@
 	m_mp_alloc_init_multi(&key->x, NULL);
 	ret = buf_getmpint(buf, key->x);
 	if (ret == DROPBEAR_FAILURE) {
-		m_mp_free_multi(&key->x);
+		m_mp_free_multi(&key->x, NULL);
 	}
 
 	return ret;