Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Feb 2020 22:36:16 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r358412 - head/contrib/sendmail/src
Message-ID:  <202002272236.01RMaGup049093@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Thu Feb 27 22:36:16 2020
New Revision: 358412
URL: https://svnweb.freebsd.org/changeset/base/358412

Log:
  Do not free p and g parameters after calling DH_set0_pqg(3).
  
  It is specifically mentioned in the manual page.  Note it has no functional
  change in reality because DH_set0_pqg() cannot fail when both p and g are
  not NULL.

Modified:
  head/contrib/sendmail/src/tls.c

Modified: head/contrib/sendmail/src/tls.c
==============================================================================
--- head/contrib/sendmail/src/tls.c	Thu Feb 27 22:02:00 2020	(r358411)
+++ head/contrib/sendmail/src/tls.c	Thu Feb 27 22:36:16 2020	(r358412)
@@ -83,20 +83,24 @@ static unsigned char dh512_g[] =
 static DH *
 get_dh512()
 {
-	DH *dh = NULL;
+	DH *dh;
 	BIGNUM *dhp_bn, *dhg_bn;
 
 	if ((dh = DH_new()) == NULL)
 		return NULL;
 	dhp_bn = BN_bin2bn(dh512_p, sizeof(dh512_p), NULL);
 	dhg_bn = BN_bin2bn(dh512_g, sizeof(dh512_g), NULL);
-	if ((dhp_bn == NULL) || (dhg_bn == NULL) || !DH_set0_pqg(dh, dhp_bn, NULL, dhg_bn))
+	if ((dhp_bn == NULL) || (dhg_bn == NULL))
 	{
-		DH_free(dh);
 		BN_free(dhp_bn);
 		BN_free(dhg_bn);
 		return NULL;
 	}
+	if (!DH_set0_pqg(dh, dhp_bn, NULL, dhg_bn))
+	{
+		DH_free(dh);
+		return NULL;
+	}
 	return dh;
 }
 
@@ -149,11 +153,15 @@ get_dh2048()
 		return NULL;
 	dhp_bn = BN_bin2bn(dh2048_p, sizeof(dh2048_p), NULL);
 	dhg_bn = BN_bin2bn(dh2048_g, sizeof(dh2048_g), NULL);
-	if ((dhp_bn == NULL) || (dhg_bn == NULL) || !DH_set0_pqg(dh, dhp_bn, NULL, dhg_bn))
+	if ((dhp_bn == NULL) || (dhg_bn == NULL))
 	{
-		DH_free(dh);
 		BN_free(dhp_bn);
 		BN_free(dhg_bn);
+		return NULL;
+	}
+	if (!DH_set0_pqg(dh, dhp_bn, NULL, dhg_bn))
+	{
+		DH_free(dh);
 		return NULL;
 	}
 	return dh;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002272236.01RMaGup049093>