if apr_generate_random_bytes fails drop into the "lame" generator instead of continuing with a null seed. This is needed for z/OS at a minimum as APR_HAS_RANDOM may be on, but if crypto hardware is not enabled the call will fail. (there are other ways apr_generate_random_bytes can fail though)
Index: apr-util/test/testdate.c
===================================================================
--- apr-util/test/testdate.c (revision 603262)
+++ apr-util/test/testdate.c (working copy)
@@ -146,6 +146,7 @@
apr_time_t offset = 0;
apr_time_t secstodate, newsecs;
char datestr[50];
+ apr_status_t rv;
for (year = 1970; year < 2038; ++year) {
secstodate = year2secs[year - 1970] + offset;
@@ -156,7 +157,10 @@
}
#if APR_HAS_RANDOM
- apr_generate_random_bytes((unsigned char *)&guess, sizeof(guess));
+ rv = apr_generate_random_bytes((unsigned char *)&guess, sizeof(guess));
+ if (rv != APR_SUCCESS) {
+ guess = apr_time_now() % APR_TIME_C(4294967291);
+ }
#else
guess = apr_time_now() % APR_TIME_C(4294967291);
#endif
testdate.random.patch
Description: Binary data
