diff --git a/src/imap.c b/src/imap.c index 841c4163..d52bb181 100644 --- a/src/imap.c +++ b/src/imap.c @@ -87,12 +87,25 @@ END: int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sdata, struct __data *data, int use_ssl, int dryrun, struct __config *cfg){ - int rc=ERR, i, n, messages=0, len, readlen, fd, nreads, readpos, finished, msglen, msg_written_len, tagoklen, tagbadlen, result; - char *p, tag[SMALLBUFSIZE], tagok[SMALLBUFSIZE], tagbad[SMALLBUFSIZE], buf[MAXBUFSIZE], puf[MAXBUFSIZE], filename[SMALLBUFSIZE]; + int rc=ERR, i, n, messages=0, len, readlen, fd, nreads, readpos, finished, msglen, msg_written_len, tagoklen, tagbadlen, result, fpos=0; + char *p, tag[SMALLBUFSIZE], tagok[SMALLBUFSIZE], tagbad[SMALLBUFSIZE], buf[MAXBUFSIZE], puf[MAXBUFSIZE], filename[SMALLBUFSIZE], __folder[SMALLBUFSIZE]; /* imap cmd: SELECT */ - snprintf(buf, sizeof(buf)-1, "A%d SELECT \"%s\"\r\n", *seq, folder); + memset(__folder, 0, sizeof(__folder)); + + for(; *folder; folder++){ + if(fpos < sizeof(__folder)-2){ + if(*folder == '"'){ + __folder[fpos] = '\\'; + fpos++; + } + __folder[fpos] = *folder; + fpos++; + } + } + + snprintf(buf, sizeof(buf)-1, "A%d SELECT \"%s\"\r\n", *seq, __folder); n = write1(sd, buf, strlen(buf), use_ssl, data->ssl); if(read_response(sd, buf, sizeof(buf), seq, data, use_ssl) == 0){ diff --git a/src/pilerimport.c b/src/pilerimport.c index 20d8e56e..42554c4d 100644 --- a/src/pilerimport.c +++ b/src/pilerimport.c @@ -351,7 +351,7 @@ ENDE_IMAP: int import_from_pop3_server(char *server, char *username, char *password, int port, struct session_data *sdata, struct __data *data, int dryrun, struct __config *cfg){ int rc, ret=OK, sd, use_ssl=0; - char port_string[6]; + char port_string[8]; struct addrinfo hints, *res; snprintf(port_string, sizeof(port_string)-1, "%d", port);