[gnutls-devel] [PATCH] gnutls_dh_get_prime_bits: return 0 if DH is not used

Armin Burgmeier armin at arbur.net
Sun May 24 05:30:18 CEST 2015


Before, the number of bits of a zero-length number was attempted to be
extracted, resulting in an error. The changed behaviour is consistent with
the documentation which explicitly states that 0 should be returned if no DH
key exchange was performed.
---
 lib/gnutls_ui.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/gnutls_ui.c b/lib/gnutls_ui.c
index f557f6c..f5e8530 100644
--- a/lib/gnutls_ui.c
+++ b/lib/gnutls_ui.c
@@ -362,6 +362,9 @@ int gnutls_dh_get_prime_bits(gnutls_session_t session)
 		return GNUTLS_E_INVALID_REQUEST;
 	}
 
+	if(dh->prime.size == 0)
+		return 0;
+
 	return mpi_buf2bits(&dh->prime);
 }
 
-- 
2.1.4




More information about the Gnutls-devel mailing list