imap fix;

This commit is contained in:
Alexander Vdolainen 2021-03-19 00:16:38 +02:00
parent ef5042412b
commit 573e0a9eaa
2 changed files with 13 additions and 1 deletions

View File

@ -11,7 +11,7 @@ AM_CFLAGS = -Wall -g
bin_PROGRAMS = ejabberdauth
ejabberdauth_SOURCES = main.c eport.c tls.c
ejabberdauth_SOURCES = main.c eport.c tls.c imap.c
ejabberdauth_LDADD = $(LIBS) $(OPENSSL_LIBS)

View File

@ -76,5 +76,17 @@ int imap_auth(struct tlsport *p, struct ejabber_msg *m)
if(strncmp(buf, "a OK", 4)) return -1;
/* check for leftovers */
if(len == IMAPLINE_LENGTH - sizeof(char)) {
do {
len = tls_io(p, buf, IMAPLINE_LENGTH - sizeof(char), TLSIO_READ);
} while(len == IMAPLINE_LENGTH - sizeof(char));
memset(buf, '\0', IMAPLINE_LENGTH);
} else memset(buf, '\0', len = sizeof(char));
/* say logout */
snprintf(buf, IMAPLINE_LENGTH - sizeof(char), "a logout");
len = tls_io(p, buf, 9, TLSIO_WRITE);
return 0;
}