-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't case arc4random: oconfigure provides.
- Loading branch information
1 parent
4afd4c5
commit 18cab7e
Showing
11 changed files
with
11 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/* $Id$ */ | ||
/* | ||
* Copyright (c) 2015--2016, 2018 Kristaps Dzonsons <[email protected]> | ||
* Copyright (c) Kristaps Dzonsons <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -169,11 +168,7 @@ kfcgi_control(int work, int ctrl, | |
|
||
/* This doesn't need to be crypto quality. */ | ||
|
||
#if HAVE_ARC4RANDOM | ||
cookie = arc4random(); | ||
#else | ||
cookie = random(); | ||
#endif | ||
|
||
/* Write a header cookie to the work. */ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/* $Id$ */ | ||
/* | ||
* Copyright (c) 2015--2016 Kristaps Dzonsons <[email protected]> | ||
* Copyright (c) Kristaps Dzonsons <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -681,11 +680,7 @@ varpool(size_t wsz, size_t maxwsz, time_t waittime, | |
|
||
assert(i < wsz); | ||
ws[i].fd = afd; | ||
#if HAVE_ARC4RANDOM | ||
ws[i].cookie = arc4random(); | ||
#else | ||
ws[i].cookie = random(); | ||
#endif | ||
dbg("worker-%u: acquire %d " | ||
"(pollers %zu/%zu: workers %zu/%zu)", | ||
ws[i].pid, afd, pfdsz, pfdmaxsz, wsz, maxwsz); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/* $Id$ */ | ||
/* | ||
* Copyright (c) 2020 Kristaps Dzonsons <[email protected]> | ||
* Copyright (c) Kristaps Dzonsons <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -53,11 +52,7 @@ main(int argc, char *argv[]) | |
*/ | ||
|
||
for (i = 0; i < 100000; i++) { | ||
#if HAVE_ARC4RANDOM | ||
v = (time_t)arc4random(); | ||
#else | ||
v = (time_t)random(); | ||
#endif | ||
if (!KHTTP_EPOCH2TM(v, &test)) | ||
errx(1, "KHTTP_EPOCH2TM"); | ||
|
||
|
@@ -84,11 +79,7 @@ main(int argc, char *argv[]) | |
} | ||
|
||
for (i = 0; i < 100000; i++) { | ||
#if HAVE_ARC4RANDOM | ||
v = (time_t)arc4random() * -1; | ||
#else | ||
v = (time_t)random() * -1; | ||
#endif | ||
if (!KHTTP_EPOCH2TM(v, &test)) | ||
errx(1, "KHTTP_EPOCH2TM"); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/* $Id$ */ | ||
/* | ||
* Copyright (c) 2016 Kristaps Dzonsons <[email protected]> | ||
* Copyright (c) Kristaps Dzonsons <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -41,19 +40,7 @@ main(int argc, char *argv[]) | |
char inbuf[64], testbuf[64]; | ||
|
||
for (i = 0; i < 100000; i++) { | ||
/* | ||
* arc4random_uniform is of course fine on BSD systems, | ||
* but isn't implemented properly on all systems, e.g., | ||
* Alpine Linux, so we don't pull in <bsd/stdlib.h> and | ||
* this might cause compile problems. | ||
* We would do more values, but Linux sometimes has | ||
* 32-bit time. | ||
*/ | ||
#if HAVE_ARC4RANDOM | ||
v = arc4random_uniform(50 * 365 * 24 * 60 * 60); | ||
#else | ||
v = random() % (50 * 365 * 24 * 60 * 60); | ||
#endif | ||
tm = gmtime(&v); | ||
strftime(inbuf, sizeof(inbuf), "%a, %d %b %Y %T GMT", tm); | ||
kutil_epoch2str(v, testbuf, sizeof(testbuf)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/* $Id$ */ | ||
/* | ||
* Copyright (c) 2020 Kristaps Dzonsons <[email protected]> | ||
* Copyright (c) Kristaps Dzonsons <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -46,11 +45,7 @@ main(int argc, char *argv[]) | |
*/ | ||
|
||
for (i = 0; i < 100000; i++) { | ||
#if HAVE_ARC4RANDOM | ||
v = arc4random(); | ||
#else | ||
v = random(); | ||
#endif | ||
if (!KHTTP_EPOCH2TM(v, &test)) | ||
errx(1, "KHTTP_EPOCH2TM"); | ||
if (!khttp_datetime2epoch(&res, | ||
|
@@ -67,11 +62,7 @@ main(int argc, char *argv[]) | |
} | ||
|
||
for (i = 0; i < 100000; i++) { | ||
#if HAVE_ARC4RANDOM | ||
v = (int64_t)arc4random() * -1; | ||
#else | ||
v = (int64_t)random() * -1; | ||
#endif | ||
if (!KHTTP_EPOCH2TM(v, &test)) | ||
errx(1, "KHTTP_EPOCH2TM"); | ||
if (!khttp_datetime2epoch(&res, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/* $Id$ */ | ||
/* | ||
* Copyright (c) 2020 Kristaps Dzonsons <[email protected]> | ||
* Copyright (c) Kristaps Dzonsons <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -95,14 +94,7 @@ main(int argc, char *argv[]) | |
/* Test across random values. */ | ||
|
||
for (i = 0; i < 100000; i++) { | ||
#if HAVE_ARC4RANDOM | ||
arc4random_buf(&v, sizeof(int64_t)); | ||
#else | ||
vv = (int64_t)random() * (int64_t)random(); | ||
memcpy(&v, &vv, sizeof(uint32_t)); | ||
vv = (int64_t)random() * (int64_t)random(); | ||
memcpy((void *)&v + sizeof(uint32_t), &vv, sizeof(uint32_t)); | ||
#endif | ||
khttp_epoch2datetime(v, | ||
&tm_sec, | ||
&tm_min, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/* $Id$ */ | ||
/* | ||
* Copyright (c) 2016, 2020 Kristaps Dzonsons <[email protected]> | ||
* Copyright (c) Kristaps Dzonsons <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -47,11 +46,7 @@ main(int argc, char *argv[]) | |
*/ | ||
|
||
for (i = 0; i < 100000; i++) { | ||
#if HAVE_ARC4RANDOM | ||
v = (int32_t)arc4random(); | ||
#else | ||
v = (int32_t)(random() + random()); | ||
#endif | ||
tm = gmtime(&v); | ||
strftime(buf, sizeof(buf), "%a, %d %b %Y %T GMT", tm); | ||
khttp_epoch2str(v, testbuf, sizeof(testbuf)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/* $Id$ */ | ||
/* | ||
* Copyright (c) 2020 Kristaps Dzonsons <[email protected]> | ||
* Copyright (c) Kristaps Dzonsons <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -47,11 +46,7 @@ main(int argc, char *argv[]) | |
*/ | ||
|
||
for (i = 0; i < 100000; i++) { | ||
#if HAVE_ARC4RANDOM | ||
v = (int32_t)arc4random(); | ||
#else | ||
v = (int32_t)(random() + random()); | ||
#endif | ||
if ((tm = gmtime(&v)) == NULL) | ||
err(1, "gmtime"); | ||
have = *tm; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/* $Id$ */ | ||
/* | ||
* Copyright (c) 2020 Kristaps Dzonsons <[email protected]> | ||
* Copyright (c) Kristaps Dzonsons <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -43,11 +42,7 @@ main(int argc, char *argv[]) | |
int c; | ||
|
||
for (i = 0; i < 100000; i++) { | ||
#if HAVE_ARC4RANDOM | ||
v = (time_t)arc4random(); | ||
#else | ||
v = (time_t)random(); | ||
#endif | ||
if ((tm = gmtime(&v)) == NULL) { | ||
warnx("gmtime: %" PRId64, (int64_t)v); | ||
continue; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/* $Id$ */ | ||
/* | ||
* Copyright (c) 2016, 2020 Kristaps Dzonsons <[email protected]> | ||
* Copyright (c) Kristaps Dzonsons <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -47,11 +46,7 @@ main(int argc, char *argv[]) | |
*/ | ||
|
||
for (i = 0; i < 100000; i++) { | ||
#if HAVE_ARC4RANDOM | ||
v = (int32_t)arc4random(); | ||
#else | ||
v = (int32_t)(random() + random()); | ||
#endif | ||
tm = gmtime(&v); | ||
strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%SZ", tm); | ||
khttp_epoch2ustr(v, testbuf, sizeof(testbuf)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/* $Id$ */ | ||
/* | ||
* Copyright (c) 2015 Kristaps Dzonsons <[email protected]> | ||
* Copyright (c) Kristaps Dzonsons <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
|
@@ -30,9 +29,6 @@ | |
#if HAVE_ZLIB | ||
|
||
#define BUFSZ (1024 * 1024) | ||
#ifdef __linux__ | ||
#define arc4random random | ||
#endif | ||
|
||
static size_t | ||
doign(void *ptr, size_t sz, size_t nm, void *arg) | ||
|