commit d61f46203962712faa1c488f3dc0a656f7e59b23
parent a8f6eebdd9233f98fc5eaefb4c5a34c3c6696d7e
Author: Klemens Nanni <kn@openbsd.org>
Date: Wed, 20 Feb 2019 19:19:58 +0100
Fix CopyArrivalDate on platforms without glibc
strptime(3)'s "%d" day of the month conversion specifier does not accept
leading blanks in case of single digit numbers. "%e" does that.
While implementation details and differences between the two
day-of-month conversion specifiers vary, none of the major libcs
(incl. OpenBSD, FreeBSD, Illumos, musl) consume a leading blank for "%d"
except glibc, which consumes any number of spaces like in the "%e" case.
Using "%e" ensures that date strings like " 4-Mar-2018 16:49:25 -0500"
are successfully parsed by all major implementations in compliance to
X/Open Portability Guide Issue 4, Version 2 ("XPG4.2"). musl is now the
only one that still treats "%d" and "%e" without stripping any space.
Issue analysed and reported by Evan Silberman <evan@jklol.net> who found
mbsync 1.3.0 on OpenBSD 6.4 to fail with `CopyArrivalDate' set when
syncing mails with the above mentioned timestamp.
See https://marc.info/?l=openbsd-tech&m=155044284526535 for details.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/drv_imap.c b/src/drv_imap.c
@@ -949,7 +949,7 @@ parse_date( const char *str )
struct tm datetime;
memset( &datetime, 0, sizeof(datetime) );
- if (!(end = strptime( str, "%d-%b-%Y %H:%M:%S ", &datetime )))
+ if (!(end = strptime( str, "%e-%b-%Y %H:%M:%S ", &datetime )))
return -1;
if ((date = timegm( &datetime )) == -1)
return -1;