apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject svn commit: r1836444 - in /apr/apr-util/branches/1.7.x: ./ crypto/ crypto/apr_crypto.c test/testcrypto.c
Date Sun, 22 Jul 2018 15:13:56 GMT
Author: minfrin
Date: Sun Jul 22 15:13:56 2018
New Revision: 1836444

URL: http://svn.apache.org/viewvc?rev=1836444&view=rev
Log:
Backport r1836438.

Make sure we compile in the absence of APU_HAVE_CRYPTO_PRNG. Make sure we don't
segfault if the PRNG does not initialise.

Modified:
    apr/apr-util/branches/1.7.x/   (props changed)
    apr/apr-util/branches/1.7.x/crypto/   (props changed)
    apr/apr-util/branches/1.7.x/crypto/apr_crypto.c
    apr/apr-util/branches/1.7.x/test/testcrypto.c

Propchange: apr/apr-util/branches/1.7.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Jul 22 15:13:56 2018
@@ -1,4 +1,4 @@
-/apr/apr/trunk:781403,781409,784519,784592,789965,794508,917837-917838,982408-982409,998533,1086937,1127053,1127648,1128838,1129433,1133587,1207704,1210524,1211987,1214516,1308087,1308131,1308318,1327636,1340286,1346865,1357761,1357772,1357780,1357966,1357968,1357979,1358295,1358480,1361811,1362241,1362248,1362252,1362255,1363076,1369681,1370626,1371811,1371817,1371919,1371923,1382174,1389154,1389169,1390461,1390477,1402870,1402897,1402903,1402907,1406088,1422413,1425356,1426442,1426448,1438960,1449308,1449314,1460185,1460243-1460244,1462219,1462224,1484271,1493715,1495887,1495889,1496407,1516261,1523479,1529554,1531009,1541054,1543399,1544846,1618843,1619438,1625247,1626561,1648830,1711657,1722547,1728958,1728963,1747941,1751567,1751806,1751898,1752008,1763665,1763667,1763669,1763672-1763673,1763842-1763843,1765378,1772414,1778153,1781391,1782042,1782045,1788335,1789947,1809394,1811470,1820080,1825311,1833359,1833366,1833382,1833421,1833425-1833426,1833440,1833449-1833451,1833456,1
 833525,1833599,1833993,1833995,1834022-1834024,1834551,1835392,1836017,1836229,1836231
+/apr/apr/trunk:781403,781409,784519,784592,789965,794508,917837-917838,982408-982409,998533,1086937,1127053,1127648,1128838,1129433,1133587,1207704,1210524,1211987,1214516,1308087,1308131,1308318,1327636,1340286,1346865,1357761,1357772,1357780,1357966,1357968,1357979,1358295,1358480,1361811,1362241,1362248,1362252,1362255,1363076,1369681,1370626,1371811,1371817,1371919,1371923,1382174,1389154,1389169,1390461,1390477,1402870,1402897,1402903,1402907,1406088,1422413,1425356,1426442,1426448,1438960,1449308,1449314,1460185,1460243-1460244,1462219,1462224,1484271,1493715,1495887,1495889,1496407,1516261,1523479,1529554,1531009,1541054,1543399,1544846,1618843,1619438,1625247,1626561,1648830,1711657,1722547,1728958,1728963,1747941,1751567,1751806,1751898,1752008,1763665,1763667,1763669,1763672-1763673,1763842-1763843,1765378,1772414,1778153,1781391,1782042,1782045,1788335,1789947,1809394,1811470,1820080,1825311,1833359,1833366,1833382,1833421,1833425-1833426,1833440,1833449-1833451,1833456,1
 833525,1833599,1833993,1833995,1834022-1834024,1834551,1835392,1836017,1836229,1836231,1836438
 /apr/apr-util/branches/1.3.x:896410,1154885
 /apr/apr-util/branches/1.4.x:1126217,1211211,1211219,1211223,1211330
 /apr/apr-util/branches/1.5.x:1757430

Propchange: apr/apr-util/branches/1.7.x/crypto/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Jul 22 15:13:56 2018
@@ -1,4 +1,4 @@
-/apr/apr/trunk/crypto:781403,781409,784519,784592,789965,794508,917837-917838,982408-982409,998533,1086937,1127053,1127648,1128838,1129433,1133587,1207704,1210524,1211987,1214516,1308087,1308131,1308318,1327636,1340286,1346865,1357761,1357772,1357780,1357966,1357968,1357979,1358295,1358480,1361811,1362241,1362248,1362252,1362255,1363076,1369681,1370626,1371811,1371817,1371919,1371923,1382174,1389154,1389169,1390461,1390477,1394552,1402870,1402897,1402903,1402907,1406088,1422413,1425356,1426442,1426448,1438960,1449308,1449314,1460185,1460243-1460244,1462219,1462224,1484271,1493715,1495887,1495889,1496407,1516261,1523479,1529554,1531009,1541054,1543399,1544846,1618843,1619438,1625247,1626561,1648830,1711657,1722547,1728958,1728963,1747941,1751806,1763665,1763667,1763669,1763672,1763842,1772414,1781391
+/apr/apr/trunk/crypto:781403,781409,784519,784592,789965,794508,917837-917838,982408-982409,998533,1086937,1127053,1127648,1128838,1129433,1133587,1207704,1210524,1211987,1214516,1308087,1308131,1308318,1327636,1340286,1346865,1357761,1357772,1357780,1357966,1357968,1357979,1358295,1358480,1361811,1362241,1362248,1362252,1362255,1363076,1369681,1370626,1371811,1371817,1371919,1371923,1382174,1389154,1389169,1390461,1390477,1394552,1402870,1402897,1402903,1402907,1406088,1422413,1425356,1426442,1426448,1438960,1449308,1449314,1460185,1460243-1460244,1462219,1462224,1484271,1493715,1495887,1495889,1496407,1516261,1523479,1529554,1531009,1541054,1543399,1544846,1618843,1619438,1625247,1626561,1648830,1711657,1722547,1728958,1728963,1747941,1751806,1763665,1763667,1763669,1763672,1763842,1772414,1781391,1836438
 /apr/apr-util/branches/1.3.x/crypto:896410,1154885
 /apr/apr-util/branches/1.4.x/crypto:1126217,1211211,1211219,1211223,1211330
 /apr/apr-util/trunk/crypto:731033-731034,731225,731236,731291,731293,731379,743986,744009,745771,747612,747623,747630,1626561

Modified: apr/apr-util/branches/1.7.x/crypto/apr_crypto.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/crypto/apr_crypto.c?rev=1836444&r1=1836443&r2=1836444&view=diff
==============================================================================
--- apr/apr-util/branches/1.7.x/crypto/apr_crypto.c (original)
+++ apr/apr-util/branches/1.7.x/crypto/apr_crypto.c Sun Jul 22 15:13:56 2018
@@ -90,9 +90,11 @@ static apr_status_t apr_crypto_term(void
 
 APU_DECLARE(apr_status_t) apr_crypto_init(apr_pool_t *pool)
 {
-    apr_status_t rv;
     apr_pool_t *rootp;
+#if APU_HAVE_CRYPTO_PRNG
+    apr_status_t rv;
     int flags = 0;
+#endif
 
     if (drivers != NULL) {
         return APR_SUCCESS;
@@ -115,6 +117,7 @@ APU_DECLARE(apr_status_t) apr_crypto_ini
     apr_pool_cleanup_register(rootp, NULL, apr_crypto_term,
                               apr_pool_cleanup_null);
 
+#if APU_HAVE_CRYPTO_PRNG
     /* apr_crypto_prng_init() may already have been called with
      * non-default parameters, so ignore APR_EREINIT.
      */
@@ -125,6 +128,7 @@ APU_DECLARE(apr_status_t) apr_crypto_ini
     if (rv != APR_SUCCESS && rv != APR_EREINIT) {
         return rv;
     }
+#endif
 
     return APR_SUCCESS;
 }

Modified: apr/apr-util/branches/1.7.x/test/testcrypto.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/test/testcrypto.c?rev=1836444&r1=1836443&r2=1836444&view=diff
==============================================================================
--- apr/apr-util/branches/1.7.x/test/testcrypto.c (original)
+++ apr/apr-util/branches/1.7.x/test/testcrypto.c Sun Jul 22 15:13:56 2018
@@ -1456,6 +1456,7 @@ static void test_crypto_equals(abts_case
     TEST_SCALAR_MATCH(6, p, 0);
 }
 
+#if APU_HAVE_CRYPTO_PRNG
 #if APU_HAVE_OPENSSL
 #include <openssl/obj_mac.h> /* for NID_* */
 #endif
@@ -1524,7 +1525,7 @@ static const unsigned char test_PRNG_kat
 static void test_crypto_prng(abts_case *tc, void *data)
 {
     unsigned char randbytes[128], seed[APR_CRYPTO_PRNG_SEED_SIZE];
-    apr_crypto_prng_t *cprng;
+    apr_crypto_prng_t *cprng = NULL;
     apr_pool_t *pool = NULL;
     apr_status_t rv;
     int i;
@@ -1553,8 +1554,10 @@ static void test_crypto_prng(abts_case *
                         rv == APR_SUCCESS);
         }
 
-        rv = apr_crypto_prng_bytes(cprng, randbytes, 128 - 32);
-        ABTS_ASSERT(tc, "apr_crypto_prng_bytes failed", rv == APR_SUCCESS);
+        if (cprng) {
+            rv = apr_crypto_prng_bytes(cprng, randbytes, 128 - 32);
+            ABTS_ASSERT(tc, "apr_crypto_prng_bytes failed", rv == APR_SUCCESS);
+        }
 
         /* Should match the first time only */
         if (i != 0) {
@@ -1568,8 +1571,10 @@ static void test_crypto_prng(abts_case *
                         memcmp(randbytes, test_PRNG_kat0 + 32, 128 - 32) == 0);
         }
 
-        rv = apr_crypto_prng_destroy(cprng);
-        ABTS_ASSERT(tc, "apr_crypto_prng_destroy failed", rv == APR_SUCCESS);
+        if (cprng) {
+            rv = apr_crypto_prng_destroy(cprng);
+            ABTS_ASSERT(tc, "apr_crypto_prng_destroy failed", rv == APR_SUCCESS);
+        }
     }
 
     apr_pool_destroy(pool);
@@ -1695,6 +1700,7 @@ static void test_crypto_thread_random(ab
     apr_pool_destroy(pool);
 }
 #endif
+#endif
 
 abts_suite *testcrypto(abts_suite *suite)
 {
@@ -1775,6 +1781,7 @@ abts_suite *testcrypto(abts_suite *suite
     abts_run_test(suite, test_crypto_memzero, NULL);
     abts_run_test(suite, test_crypto_equals, NULL);
 
+#if APU_HAVE_CRYPTO_PRNG
     abts_run_test(suite, test_crypto_prng, NULL);
 #if APR_HAS_FORK
     abts_run_test(suite, test_crypto_fork_random, NULL);
@@ -1782,6 +1789,7 @@ abts_suite *testcrypto(abts_suite *suite
 #if APR_HAS_THREADS
     abts_run_test(suite, test_crypto_thread_random, NULL);
 #endif
+#endif
 
     return suite;
 }



Mime
View raw message