Merge branch '1.3'

Conflicts:
	configure.ac
This commit is contained in:
Oswald Buddenhagen 2018-04-08 18:17:10 +02:00
commit 904858365d
9 changed files with 47 additions and 35 deletions

1
.gitignore vendored
View File

@ -21,6 +21,7 @@
/install-sh
/isync.spec
/isync-*.tar.gz
/isync-*.tar.gz.asc
/missing
/patch-stamp
/stamp-h

View File

@ -11,6 +11,23 @@ fi
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
AC_CHECK_PROG(PERL, perl, perl)
if test "x$PERL" = "x"; then
AC_MSG_ERROR([perl not found])
fi
need_perl=5.14
AC_CACHE_CHECK([whether perl is recent enough], ob_cv_perl_ver, [
if $PERL -e "use v$need_perl;"; then
ob_cv_perl_ver=yes
else
ob_cv_perl_ver=no
fi
])
if test "x$ob_cv_perl_ver" = "xno"; then
AC_MSG_ERROR([perl is too old])
fi
AC_CACHE_CHECK([whether strftime supports %z], ob_cv_strftime_z,
[AC_TRY_RUN(
[#include <time.h>

View File

@ -355,6 +355,8 @@ load_config( const char *where, int pseudo )
if (store) {
if (!store->max_size)
store->max_size = INT_MAX;
if (!store->flat_delim)
store->flat_delim = "";
*storeapp = store;
storeapp = &store->next;
*storeapp = 0;

View File

@ -2250,7 +2250,7 @@ imap_open_store_namespace( imap_store_t *ctx )
ctx->state = SST_HALF;
ctx->prefix = cfg->gen.path;
ctx->delimiter[0] = cfg->delimiter ? cfg->delimiter : 0;
ctx->delimiter[0] = cfg->delimiter;
if (((!ctx->prefix && cfg->use_namespace) || !cfg->delimiter) && CAP(NAMESPACE)) {
/* get NAMESPACE info */
if (!ctx->got_namespace)
@ -2388,7 +2388,7 @@ imap_open_box_p2( imap_store_t *ctx, imap_cmd_t *gcmd, int response )
INIT_IMAP_CMD(imap_cmd_open_box_t, cmd, cmdp->callback, cmdp->callback_aux)
cmd->gen.param.lastuid = 1;
imap_exec( ctx, &cmd->gen, imap_open_box_p3,
"UID FETCH *:* (UID)" );
"UID FETCH * (UID)" );
}
static void

View File

@ -1153,28 +1153,29 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
goto retry;
}
int off, in_msgid = 0;
while ((want_tuid || want_msgid) && fgets( nbuf, sizeof(nbuf), f )) {
int bufl = strlen( nbuf );
if (bufl && nbuf[bufl - 1] == '\n')
char lnbuf[1000]; // Says RFC2822
while ((want_tuid || want_msgid) && fgets( lnbuf, sizeof(lnbuf), f )) {
int bufl = strlen( lnbuf );
if (bufl && lnbuf[bufl - 1] == '\n')
--bufl;
if (bufl && nbuf[bufl - 1] == '\r')
if (bufl && lnbuf[bufl - 1] == '\r')
--bufl;
if (!bufl)
break;
if (want_tuid && starts_with( nbuf, bufl, "X-TUID: ", 8 )) {
if (want_tuid && starts_with( lnbuf, bufl, "X-TUID: ", 8 )) {
if (bufl < 8 + TUIDL) {
error( "Maildir error: malformed X-TUID header (UID %u)\n", uid );
continue;
}
memcpy( entry->tuid, nbuf + 8, TUIDL );
memcpy( entry->tuid, lnbuf + 8, TUIDL );
want_tuid = 0;
in_msgid = 0;
continue;
}
if (want_msgid && starts_with_upper( nbuf, bufl, "MESSAGE-ID:", 11 )) {
if (want_msgid && starts_with_upper( lnbuf, bufl, "MESSAGE-ID:", 11 )) {
off = 11;
} else if (in_msgid) {
if (!isspace( nbuf[0] )) {
if (!isspace( lnbuf[0] )) {
in_msgid = 0;
continue;
}
@ -1182,13 +1183,13 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
} else {
continue;
}
while (off < bufl && isspace( nbuf[off] ))
while (off < bufl && isspace( lnbuf[off] ))
off++;
if (off == bufl) {
in_msgid = 1;
continue;
}
entry->msgid = nfstrndup( nbuf + off, bufl - off );
entry->msgid = nfstrndup( lnbuf + off, bufl - off );
want_msgid = 0;
in_msgid = 0;
}

View File

@ -983,7 +983,7 @@ store_connected( int sts, void *aux )
flags |= LIST_INBOX;
} else if (c == '/') {
/* Flattened sub-folders of INBOX actually end up in Path. */
if (mvars->ctx[t]->conf->flat_delim)
if (mvars->ctx[t]->conf->flat_delim[0])
flags |= LIST_PATH;
else
flags |= LIST_INBOX;
@ -1027,7 +1027,7 @@ store_listed( int sts, string_list_t *boxes, void *aux )
return;
case DRV_OK:
for (box = boxes; box; box = box->next) {
if (mvars->ctx[t]->conf->flat_delim) {
if (mvars->ctx[t]->conf->flat_delim[0]) {
string_list_t *nbox;
if (map_name( box->string, (char **)&nbox, offsetof(string_list_t, string), mvars->ctx[t]->conf->flat_delim, "/" ) < 0) {
error( "Error: flattened mailbox name '%s' contains canonical hierarchy delimiter\n", box->string );

View File

@ -30,9 +30,7 @@
#endif
#ifdef HAVE_LIBSSL
typedef struct ssl_st SSL;
typedef struct ssl_ctx_st SSL_CTX;
typedef struct stack_st _STACK;
# include <openssl/ssl.h>
enum {
SSLv3 = 2,

View File

@ -1014,7 +1014,7 @@ sync_boxes( store_t *ctx[], const char *names[], int present[], channel_conf_t *
svars->orig_name[t] =
(!names[t] || (ctx[t]->conf->map_inbox && !strcmp( ctx[t]->conf->map_inbox, names[t] ))) ?
"INBOX" : names[t];
if (!ctx[t]->conf->flat_delim) {
if (!ctx[t]->conf->flat_delim[0]) {
svars->box_name[t] = nfstrdup( svars->orig_name[t] );
} else if (map_name( svars->orig_name[t], &svars->box_name[t], 0, "/", ctx[t]->conf->flat_delim ) < 0) {
error( "Error: canonical mailbox name '%s' contains flattened hierarchy delimiter\n", svars->orig_name[t] );

View File

@ -479,19 +479,20 @@ map_name( const char *arg, char **result, int reserve, const char *in, const cha
char *p;
int i, l, ll, num, inl, outl;
assert( arg );
l = strlen( arg );
if (!in) {
assert( in );
inl = strlen( in );
if (!inl) {
copy:
*result = nfmalloc( reserve + l + 1 );
memcpy( *result + reserve, arg, l + 1 );
return 0;
}
inl = strlen( in );
if (out) {
assert( out );
outl = strlen( out );
if (inl == outl && !memcmp( in, out, inl ))
if (equals( in, inl, out, outl ))
goto copy;
}
for (num = 0, i = 0; i < l; ) {
for (ll = 0; ll < inl; ll++)
if (arg[i + ll] != in[ll])
@ -500,7 +501,7 @@ map_name( const char *arg, char **result, int reserve, const char *in, const cha
i += inl;
continue;
fout:
if (out) {
if (outl) {
for (ll = 0; ll < outl; ll++)
if (arg[i + ll] != out[ll])
goto fnexti;
@ -511,7 +512,7 @@ map_name( const char *arg, char **result, int reserve, const char *in, const cha
}
if (!num)
goto copy;
if (!out)
if (!outl)
return -2;
*result = nfmalloc( reserve + l + num * (outl - inl) + 1 );
p = *result + reserve;
@ -519,15 +520,7 @@ map_name( const char *arg, char **result, int reserve, const char *in, const cha
for (ll = 0; ll < inl; ll++)
if (arg[i + ll] != in[ll])
goto rnexti;
#ifdef __GNUC__
# pragma GCC diagnostic push
/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42145 */
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
memcpy( p, out, outl );
#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif
p += outl;
i += inl;
continue;