|
|
@ -100,11 +100,11 @@ typedef struct imap_store { |
|
|
|
int ref_count; |
|
|
|
int ref_count; |
|
|
|
/* trash folder's existence is not confirmed yet */ |
|
|
|
/* trash folder's existence is not confirmed yet */ |
|
|
|
enum { TrashUnknown, TrashChecking, TrashKnown } trashnc; |
|
|
|
enum { TrashUnknown, TrashChecking, TrashKnown } trashnc; |
|
|
|
unsigned got_namespace:1; |
|
|
|
uint got_namespace:1; |
|
|
|
char *delimiter; /* hierarchy delimiter */ |
|
|
|
char *delimiter; /* hierarchy delimiter */ |
|
|
|
list_t *ns_personal, *ns_other, *ns_shared; /* NAMESPACE info */ |
|
|
|
list_t *ns_personal, *ns_other, *ns_shared; /* NAMESPACE info */ |
|
|
|
message_t **msgapp; /* FETCH results */ |
|
|
|
message_t **msgapp; /* FETCH results */ |
|
|
|
unsigned caps; /* CAPABILITY results */ |
|
|
|
uint caps; /* CAPABILITY results */ |
|
|
|
string_list_t *auth_mechs; |
|
|
|
string_list_t *auth_mechs; |
|
|
|
parse_list_state_t parse_list_sts; |
|
|
|
parse_list_state_t parse_list_sts; |
|
|
|
/* command queue */ |
|
|
|
/* command queue */ |
|
|
@ -591,7 +591,7 @@ next_arg( char **ps ) |
|
|
|
s = *ps; |
|
|
|
s = *ps; |
|
|
|
if (!s) |
|
|
|
if (!s) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
while (isspace( (unsigned char)*s )) |
|
|
|
while (isspace( (uchar)*s )) |
|
|
|
s++; |
|
|
|
s++; |
|
|
|
if (!*s) { |
|
|
|
if (!*s) { |
|
|
|
*ps = 0; |
|
|
|
*ps = 0; |
|
|
@ -613,7 +613,7 @@ next_arg( char **ps ) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ret = s; |
|
|
|
ret = s; |
|
|
|
while ((c = *s)) { |
|
|
|
while ((c = *s)) { |
|
|
|
if (isspace( (unsigned char)c )) { |
|
|
|
if (isspace( (uchar)c )) { |
|
|
|
*s++ = 0; |
|
|
|
*s++ = 0; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -684,7 +684,7 @@ parse_imap_list( imap_store_t *ctx, char **sp, parse_list_state_t *sts ) |
|
|
|
if (!s) |
|
|
|
if (!s) |
|
|
|
return LIST_BAD; |
|
|
|
return LIST_BAD; |
|
|
|
for (;;) { |
|
|
|
for (;;) { |
|
|
|
while (isspace( (unsigned char)*s )) |
|
|
|
while (isspace( (uchar)*s )) |
|
|
|
s++; |
|
|
|
s++; |
|
|
|
if (sts->level && *s == ')') { |
|
|
|
if (sts->level && *s == ')') { |
|
|
|
s++; |
|
|
|
s++; |
|
|
@ -751,7 +751,7 @@ parse_imap_list( imap_store_t *ctx, char **sp, parse_list_state_t *sts ) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
/* atom */ |
|
|
|
/* atom */ |
|
|
|
p = s; |
|
|
|
p = s; |
|
|
|
for (; *s && !isspace( (unsigned char)*s ); s++) |
|
|
|
for (; *s && !isspace( (uchar)*s ); s++) |
|
|
|
if (sts->level && *s == ')') |
|
|
|
if (sts->level && *s == ')') |
|
|
|
break; |
|
|
|
break; |
|
|
|
cur->len = s - p; |
|
|
|
cur->len = s - p; |
|
|
@ -876,7 +876,7 @@ parse_fetch_rsp( imap_store_t *ctx, list_t *list, char *s ATTR_UNUSED ) |
|
|
|
msg_data_t *msgdata; |
|
|
|
msg_data_t *msgdata; |
|
|
|
struct imap_cmd *cmdp; |
|
|
|
struct imap_cmd *cmdp; |
|
|
|
int uid = 0, mask = 0, status = 0, size = 0; |
|
|
|
int uid = 0, mask = 0, status = 0, size = 0; |
|
|
|
unsigned i; |
|
|
|
uint i; |
|
|
|
time_t date = 0; |
|
|
|
time_t date = 0; |
|
|
|
|
|
|
|
|
|
|
|
if (!is_list( list )) { |
|
|
|
if (!is_list( list )) { |
|
|
@ -1000,7 +1000,7 @@ static void |
|
|
|
parse_capability( imap_store_t *ctx, char *cmd ) |
|
|
|
parse_capability( imap_store_t *ctx, char *cmd ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char *arg; |
|
|
|
char *arg; |
|
|
|
unsigned i; |
|
|
|
uint i; |
|
|
|
|
|
|
|
|
|
|
|
free_string_list( ctx->auth_mechs ); |
|
|
|
free_string_list( ctx->auth_mechs ); |
|
|
|
ctx->auth_mechs = 0; |
|
|
|
ctx->auth_mechs = 0; |
|
|
@ -1052,7 +1052,7 @@ parse_response_code( imap_store_t *ctx, struct imap_cmd *cmd, char *s ) |
|
|
|
/* RFC2060 says that these messages MUST be displayed
|
|
|
|
/* RFC2060 says that these messages MUST be displayed
|
|
|
|
* to the user |
|
|
|
* to the user |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
for (; isspace( (unsigned char)*p ); p++); |
|
|
|
for (; isspace( (uchar)*p ); p++); |
|
|
|
error( "*** IMAP ALERT *** %s\n", p ); |
|
|
|
error( "*** IMAP ALERT *** %s\n", p ); |
|
|
|
} else if (cmd && !strcmp( "APPENDUID", arg )) { |
|
|
|
} else if (cmd && !strcmp( "APPENDUID", arg )) { |
|
|
|
if (!(arg = next_arg( &s )) || |
|
|
|
if (!(arg = next_arg( &s )) || |
|
|
@ -1743,8 +1743,8 @@ process_sasl_interact( sasl_interact_t *interact, imap_server_conf_t *srvc ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int |
|
|
|
static int |
|
|
|
process_sasl_step( imap_store_t *ctx, int rc, const char *in, unsigned in_len, |
|
|
|
process_sasl_step( imap_store_t *ctx, int rc, const char *in, uint in_len, |
|
|
|
sasl_interact_t *interact, const char **out, unsigned *out_len ) |
|
|
|
sasl_interact_t *interact, const char **out, uint *out_len ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
imap_server_conf_t *srvc = ((imap_store_conf_t *)ctx->gen.conf)->server; |
|
|
|
imap_server_conf_t *srvc = ((imap_store_conf_t *)ctx->gen.conf)->server; |
|
|
|
|
|
|
|
|
|
|
@ -1765,11 +1765,11 @@ process_sasl_step( imap_store_t *ctx, int rc, const char *in, unsigned in_len, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int |
|
|
|
static int |
|
|
|
decode_sasl_data( const char *prompt, char **in, unsigned *in_len ) |
|
|
|
decode_sasl_data( const char *prompt, char **in, uint *in_len ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (prompt) { |
|
|
|
if (prompt) { |
|
|
|
int rc; |
|
|
|
int rc; |
|
|
|
unsigned prompt_len = strlen( prompt ); |
|
|
|
uint prompt_len = strlen( prompt ); |
|
|
|
/* We're decoding, the output will be shorter than prompt_len. */ |
|
|
|
/* We're decoding, the output will be shorter than prompt_len. */ |
|
|
|
*in = nfmalloc( prompt_len ); |
|
|
|
*in = nfmalloc( prompt_len ); |
|
|
|
rc = sasl_decode64( prompt, prompt_len, *in, prompt_len, in_len ); |
|
|
|
rc = sasl_decode64( prompt, prompt_len, *in, prompt_len, in_len ); |
|
|
@ -1786,10 +1786,10 @@ decode_sasl_data( const char *prompt, char **in, unsigned *in_len ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int |
|
|
|
static int |
|
|
|
encode_sasl_data( const char *out, unsigned out_len, char **enc, unsigned *enc_len ) |
|
|
|
encode_sasl_data( const char *out, uint out_len, char **enc, uint *enc_len ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int rc; |
|
|
|
int rc; |
|
|
|
unsigned enc_len_max = ((out_len + 2) / 3) * 4 + 1; |
|
|
|
uint enc_len_max = ((out_len + 2) / 3) * 4 + 1; |
|
|
|
*enc = nfmalloc( enc_len_max ); |
|
|
|
*enc = nfmalloc( enc_len_max ); |
|
|
|
rc = sasl_encode64( out, out_len, *enc, enc_len_max, enc_len ); |
|
|
|
rc = sasl_encode64( out, out_len, *enc, enc_len_max, enc_len ); |
|
|
|
if (rc != SASL_OK) { |
|
|
|
if (rc != SASL_OK) { |
|
|
@ -1804,7 +1804,7 @@ static int |
|
|
|
do_sasl_auth( imap_store_t *ctx, struct imap_cmd *cmdp ATTR_UNUSED, const char *prompt ) |
|
|
|
do_sasl_auth( imap_store_t *ctx, struct imap_cmd *cmdp ATTR_UNUSED, const char *prompt ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int rc, ret; |
|
|
|
int rc, ret; |
|
|
|
unsigned in_len, out_len, enc_len; |
|
|
|
uint in_len, out_len, enc_len; |
|
|
|
const char *out; |
|
|
|
const char *out; |
|
|
|
char *in, *enc; |
|
|
|
char *in, *enc; |
|
|
|
sasl_interact_t *interact = NULL; |
|
|
|
sasl_interact_t *interact = NULL; |
|
|
@ -1851,7 +1851,7 @@ done_sasl_auth( imap_store_t *ctx, struct imap_cmd *cmd ATTR_UNUSED, int respons |
|
|
|
if (response == RESP_OK && ctx->sasl_cont) { |
|
|
|
if (response == RESP_OK && ctx->sasl_cont) { |
|
|
|
sasl_interact_t *interact = NULL; |
|
|
|
sasl_interact_t *interact = NULL; |
|
|
|
const char *out; |
|
|
|
const char *out; |
|
|
|
unsigned out_len; |
|
|
|
uint out_len; |
|
|
|
int rc = sasl_client_step( ctx->sasl, NULL, 0, &interact, &out, &out_len ); |
|
|
|
int rc = sasl_client_step( ctx->sasl, NULL, 0, &interact, &out, &out_len ); |
|
|
|
if (process_sasl_step( ctx, rc, NULL, 0, interact, &out, &out_len ) < 0) |
|
|
|
if (process_sasl_step( ctx, rc, NULL, 0, interact, &out, &out_len ) < 0) |
|
|
|
warn( "Warning: SASL reported failure despite successful IMAP authentication. Ignoring...\n" ); |
|
|
|
warn( "Warning: SASL reported failure despite successful IMAP authentication. Ignoring...\n" ); |
|
|
@ -1904,7 +1904,7 @@ imap_open_store_authenticate2( imap_store_t *ctx ) |
|
|
|
#ifdef HAVE_LIBSASL |
|
|
|
#ifdef HAVE_LIBSASL |
|
|
|
if (saslend != saslmechs) { |
|
|
|
if (saslend != saslmechs) { |
|
|
|
int rc; |
|
|
|
int rc; |
|
|
|
unsigned out_len = 0; |
|
|
|
uint out_len = 0; |
|
|
|
char *enc = NULL; |
|
|
|
char *enc = NULL; |
|
|
|
const char *gotmech = NULL, *out = NULL; |
|
|
|
const char *gotmech = NULL, *out = NULL; |
|
|
|
sasl_interact_t *interact = NULL; |
|
|
|
sasl_interact_t *interact = NULL; |
|
|
@ -2198,7 +2198,7 @@ static int |
|
|
|
imap_make_flags( int flags, char *buf ) |
|
|
|
imap_make_flags( int flags, char *buf ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const char *s; |
|
|
|
const char *s; |
|
|
|
unsigned i, d; |
|
|
|
uint i, d; |
|
|
|
|
|
|
|
|
|
|
|
for (i = d = 0; i < as(Flags); i++) |
|
|
|
for (i = d = 0; i < as(Flags); i++) |
|
|
|
if (flags & (1 << i)) { |
|
|
|
if (flags & (1 << i)) { |
|
|
|