IMAP auth function fixed;

master
Alexander Vdolainen 4 years ago
parent 1b399ffdbb
commit 0311922818

@ -57,16 +57,16 @@ int imap_auth(struct tlsport *p, struct ejabber_msg *m)
len = tls_io(p, buf, IMAPLINE_LENGTH - sizeof(char), TLSIO_READ); len = tls_io(p, buf, IMAPLINE_LENGTH - sizeof(char), TLSIO_READ);
} while(len == IMAPLINE_LENGTH - sizeof(char)); } while(len == IMAPLINE_LENGTH - sizeof(char));
memset(buf, '\0', IMAPLINE_LENGTH); memset(buf, '\0', IMAPLINE_LENGTH);
} else memset(buf, '\0', len = sizeof(char)); } else memset(buf, '\0', len + sizeof(char));
/* try to login with provided credentials */ /* try to login with provided credentials */
mlen = strlen(m->user) + strlen(m->domain) + strlen(m->password); mlen = strlen(m->user) + strlen(m->domain) + strlen(m->password);
mlen += 14; /* "a login 11 22" */ mlen += 16; /* "a login 11 22" */
if(mlen > IMAPLINE_LENGTH - sizeof(char)) return -1; /* too long */ if(mlen > IMAPLINE_LENGTH - sizeof(char)) return -1; /* too long */
/* create a message */ /* create a message */
snprintf(buf, mlen, "a login \"%s@%s\" \"%s\"", m->user, m->domain, snprintf(buf, mlen, "a login \"%s@%s\" \"%s\"\n", m->user, m->domain,
m->password); m->password);
len = tls_io(p, buf, mlen, TLSIO_WRITE); len = tls_io(p, buf, mlen - sizeof(char), TLSIO_WRITE);
if(len < 0) return -1; if(len < 0) return -1;
else memset(buf, '\0', mlen); else memset(buf, '\0', mlen);

Loading…
Cancel
Save