mirror of
https://bjh21.me.uk/bedstead/.git
synced 2026-08-08 17:30:29 -04:00
Further SOURCE_DATE_EPOCH simplification
Rather than mucking about with errno, we can just take advantage of the fact that on overflow, strtoull() is specified to return ULLONG_MAX, which is guaranteed to be (much) bigger than the maximum SOURCE_DATE_EPOCH that we can cope with. So our usual range check can cope with overflow as well.
This commit is contained in:
parent
528c0542ed
commit
0d2296e4af
@ -98,7 +98,6 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@ -3149,11 +3148,9 @@ time_for_ttx(void)
|
||||
|
||||
/* Work out what timestamp to use. */
|
||||
if ((epochstr = getenv("SOURCE_DATE_EPOCH")) != NULL) {
|
||||
errno = 0;
|
||||
epochull = strtoull(epochstr, &endptr, 10);
|
||||
if (!isdigit((unsigned char)epochstr[0]) ||
|
||||
endptr == epochstr || *endptr != '\0' ||
|
||||
errno == ERANGE ||
|
||||
/* Allow years up to 9999. */
|
||||
epochull >= 253402300800) {
|
||||
fprintf(stderr, "Invalid SOURCE_DATE_EPOCH\n");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user