diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2023-04-11 11:59:08 +0100 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2023-04-11 11:59:08 +0100 |
commit | 51f9c07cd341c9c1a09b3816df988c6f44477c99 (patch) | |
tree | 464c8c1bebc9684e6146c39d63acfc20b1f18b56 | |
parent | 12e1cfcb1649e2ea213c2965adf8479f1cff06f7 (diff) |
Fix ${srs_encode ..} for mod-1024 day zero
-rw-r--r-- | doc/doc-txt/ChangeLog | 3 | ||||
-rw-r--r-- | src/src/expand.c | 10 |
2 files changed, 7 insertions, 6 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 16d2b8ef8..d29ba6f65 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -122,6 +122,9 @@ JH/25 Bug 2827: Restrict size of References: header in bounce messages to 998 JH/26 For a ${readsocket } in TLS mode, send a TLS Close Alert before the TCP close. Previously a bare socket close was done. +JH/27 Fix ${srs_encode ..}. Previously it would give a bad result for one day + every 1024 days. + Exim version 4.96 ----------------- diff --git a/src/src/expand.c b/src/src/expand.c index fe0fd1469..26df25795 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -3523,7 +3523,7 @@ switch(cond_type = identify_operator(&s, &opname)) /* Match the given local_part against the SRS-encoded pattern */ - re = regex_must_compile(US"^(?i)SRS0=([^=]+)=([A-Z2-7]+)=([^=]*)=(.*)$", + re = regex_must_compile(US"^(?i)SRS0=([^=]+)=([A-Z2-7]{2})=([^=]*)=(.*)$", MCS_CASELESS | MCS_CACHEABLE, FALSE); md = pcre2_match_data_create(4+1, pcre_gen_ctx); if (pcre2_match(re, sub[0], PCRE2_ZERO_TERMINATED, 0, PCRE_EOPT, @@ -7061,13 +7061,11 @@ while (*s) { struct timeval now; unsigned long i; - gstring * h = NULL; gettimeofday(&now, NULL); - for (unsigned long i = (now.tv_sec / 86400) & 0x3ff; i; i >>= 5) - h = string_catn(h, &base32_chars[i & 0x1f], 1); - if (h) while (h->ptr > 0) - g = string_catn(g, &h->s[--h->ptr], 1); + i = (now.tv_sec / 86400) & 0x3ff; + g = string_catn(g, &base32_chars[i >> 5], 1); + g = string_catn(g, &base32_chars[i & 0x1f], 1); } g = string_catn(g, US"=", 1); |