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;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to