commit d61f46203962712faa1c488f3dc0a656f7e59b23
Author:     Klemens Nanni <k...@openbsd.org>
AuthorDate: Wed Feb 20 19:19:58 2019 +0100
Commit:     Oswald Buddenhagen <o...@users.sf.net>
CommitDate: Wed Feb 20 23:02:02 2019 +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 <e...@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.

 src/drv_imap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/drv_imap.c b/src/drv_imap.c
index d92e218..8a7e9be 100644
--- 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;


_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to