From 4b37be8f19bcb839e3bb3aaf4ea5939758dae80b Mon Sep 17 00:00:00 2001 From: SJ Date: Wed, 21 Nov 2012 22:01:06 +0100 Subject: [PATCH] changed the imap auth command from authenticate to login --- src/imap.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/imap.c b/src/imap.c index 02395fd3..93fa6786 100644 --- a/src/imap.c +++ b/src/imap.c @@ -211,10 +211,8 @@ int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sda int connect_to_imap_server(int sd, int *seq, char *imapserver, char *username, char *password, int port, struct __data *data, int use_ssl){ - int n, pos=0; + int n; char tag[SMALLBUFSIZE], tagok[SMALLBUFSIZE], buf[MAXBUFSIZE]; - char auth[2*SMALLBUFSIZE]; - unsigned char tmp[SMALLBUFSIZE]; unsigned long host=0; struct sockaddr_in remote_addr; X509* server_cert; @@ -273,25 +271,15 @@ int connect_to_imap_server(int sd, int *seq, char *imapserver, char *username, c n = recvtimeoutssl(sd, buf, sizeof(buf), 10, use_ssl, data->ssl); - /* - * create auth buffer: username + NUL character + username + NUL character + password - */ + snprintf(tag, sizeof(tag)-1, "A%d", *seq); snprintf(tagok, sizeof(tagok)-1, "A%d OK", (*seq)++); + snprintf(buf, sizeof(buf)-1, "%s CAPABILITY\r\n", tag); - memset(tmp, 0, sizeof(tmp)); - pos = 0; + write1(sd, buf, use_ssl, data->ssl); + n = recvtimeoutssl(sd, buf, sizeof(buf), 10, use_ssl, data->ssl); - memcpy(tmp+pos, username, strlen(username)); - pos = strlen(username) + 1; - memcpy(tmp+pos, username, strlen(username)); - pos += strlen(username) + 1; - memcpy(tmp+pos, password, strlen(password)); - pos += strlen(password); - - - base64_encode(&tmp[0], pos, &auth[0], sizeof(auth)); snprintf(tag, sizeof(tag)-1, "A%d", *seq); snprintf(tagok, sizeof(tagok)-1, "A%d OK", (*seq)++); - snprintf(buf, sizeof(buf)-1, "%s AUTHENTICATE PLAIN %s\r\n", tag, auth); + snprintf(buf, sizeof(buf)-1, "%s LOGIN %s %s\r\n", tag, username, password); write1(sd, buf, use_ssl, data->ssl); n = recvtimeoutssl(sd, buf, sizeof(buf), 10, use_ssl, data->ssl);