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.
#include <assert.h>
#include <ctype.h>
-#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
/* 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");