From 12eecc5d6ad7fe06edd0d872c05b1a772afd8a65 Mon Sep 17 00:00:00 2001 From: Richard T Bonhomme Date: Thu, 5 May 2022 14:58:27 +0100 Subject: [PATCH] Replace arithmetic number overflow with sensible error detection code Windows sh.exe cannot multiply two date stamps due to 32bit integer overflow. Signed-off-by: Richard T Bonhomme --- easyrsa3/easyrsa | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/easyrsa3/easyrsa b/easyrsa3/easyrsa index d454133..4b251ea 100755 --- a/easyrsa3/easyrsa +++ b/easyrsa3/easyrsa @@ -1700,8 +1700,16 @@ Non-decimal value for EASYRSA_FIX_OFFSET: '$EASYRSA_FIX_OFFSET'" # Do not generate an expired, fixed date certificate if [ "$EASYRSA_FIX_OFFSET" ]; then - [ "$(( now_sec * end_fix_sec ))" -gt 0 ] \ - || die "Undefined: now_sec, end_fix_sec" + for date_stamp in "${now_sec}" "${end_fix_sec}"; do + case "${date_stamp}" in + ''|*[!1234567890]*|0*) + die "Undefined: '$now_sec', '$end_fix_sec'" + ;; + *) + [ "${#date_stamp}" -eq 10 ] \ + || die "Undefined: $now_sec, $end_fix_sec" + esac + done [ "$now_sec" -lt "$end_fix_sec" ] || die "\ The lifetime of the certificate will expire before the date today." [ "$start_fixdate" ] || die "Undefined: start_fixdate"