MCPcopy Create free account
hub / github.com/apache/httpd / ap_random_pick

Function ap_random_pick

server/core.c:5493–5512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5491#define RAND_RANGE(__n, __min, __max, __tmax) \
5492(__n) = (__min) + (long) ((double) ((__max) - (__min) + 1.0) * ((__n) / ((__tmax) + 1.0)))
5493AP_DECLARE(apr_uint32_t) ap_random_pick(apr_uint32_t min, apr_uint32_t max)
5494{
5495 apr_uint32_t number;
5496#if (!__GNUC__ || __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || \
5497 !__sparc__ || APR_SIZEOF_VOIDP != 8)
5498 /* This triggers a gcc bug on sparc/64bit with gcc < 4.8, PR 52900 */
5499 if (max < 16384) {
5500 apr_uint16_t num16;
5501 ap_random_insecure_bytes(&num16, sizeof(num16));
5502 RAND_RANGE(num16, min, max, APR_UINT16_MAX);
5503 number = num16;
5504 }
5505 else
5506#endif
5507 {
5508 ap_random_insecure_bytes(&number, sizeof(number));
5509 RAND_RANGE(number, min, max, APR_UINT32_MAX);
5510 }
5511 return number;
5512}
5513
5514static apr_status_t core_insert_network_bucket(conn_rec *c,
5515 apr_bucket_brigade *bb,

Callers 3

find_best_hbFunction · 0.85
select_random_value_partFunction · 0.85
select_padding_cbFunction · 0.85

Calls 1

ap_random_insecure_bytesFunction · 0.85

Tested by

no test coverage detected