summaryrefslogtreecommitdiff
path: root/src/qmail-remote.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmail-remote.c')
-rw-r--r--src/qmail-remote.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/qmail-remote.c b/src/qmail-remote.c
index d2f08dd..fc90cd4 100644
--- a/src/qmail-remote.c
+++ b/src/qmail-remote.c
@@ -42,7 +42,7 @@
#include "uint_t.h"
#define WHO "qmail-remote"
-
+
#define QMTP_MAX 200000000 /* 190 MB for QMTP */
#define HUGESMTPTEXT 1000 /* RFC 5322; was 5000 chars/line */
#define PORT_SMTP 25 /* silly rabbit, /etc/services is for users */
@@ -166,14 +166,14 @@ void temp_osip()
}
void temp_noconn()
{
- out("ZSorry, I wasn't able to establish an SMTP connection: ");
+ out("ZSorry, I wasn't able to establish a SMTP connection: ");
outsafe(&canonhost);
out(". (#4.3.0)\n");
zerodie();
}
void temp_qmtpnoc()
{
- out("ZSorry, I wasn't able to establish an QMTP connection: ");
+ out("ZSorry, I wasn't able to establish a QMTP connection: ");
outsafe(&canonhost);
out(". (#4.3.1)\n");
zerodie();
@@ -313,7 +313,7 @@ ssize_t safewrite(int fd,char *buf,int len)
char inbuf[BUFSIZE_LINE];
buffer bi = BUFFER_INIT(read,0,inbuf,sizeof(inbuf));
-char outbuf[BUFSIZE_MESS];
+char outbuf[BUFSIZE_LINE];
buffer bo = BUFFER_INIT(safewrite,-1,outbuf,sizeof(outbuf));
char frombuf[BUFFER_SMALL];
buffer bf = BUFFER_INIT(saferead,-1,frombuf,sizeof(frombuf));
@@ -478,9 +478,10 @@ int starttls_peer()
{
int i = 0;
- if (smtptext.len > 16)
- for (i = 0; i < smtptext.len - 8; ++i)
- if (case_starts(smtptext.s + i,"STARTTLS")) return 1;
+ while ((i += str_chr(smtptext.s + i,'\n') + 1) &&
+ (i + 8 < smtptext.len) ) {
+ if (!str_diffn(smtptext.s + i + 4,"STARTTLS",8)) return 1;
+ }
return 0;
}
@@ -489,7 +490,7 @@ void tls_peercheck()
{
X509 *cert;
STACK_OF(X509) *certs;
-
+
cert = SSL_get_peer_certificate(ssl);
if (!cert) { flagtls = 100; return; }
@@ -597,10 +598,12 @@ int flagsize = 0;
int smtp_size()
{
int i;
- if (smtptext.len > 10)
- for (i = 0; i < smtptext.len; ++i) {
- if (case_starts(smtptext.s + i,"SIZE ")) return 1;
- }
+
+ while ((i += str_chr(smtptext.s + i,'\n') + 1) &&
+ (i + 8 <= smtptext.len) ) {
+ if (!str_diffn(smtptext.s + i + 4,"SIZE",4)) return 1;
+ }
+
return 0;;
}
@@ -814,15 +817,18 @@ void smtp_auth()
{
int i;
- if (smtptext.len > 8)
- for (i = 4; i < smtptext.len - 5; ++i) {
- if (case_starts(smtptext.s + i,"CRAM"))
+ while ((i += str_chr(smtptext.s + i,'\n') + 1) &&
+ (i + 8 < smtptext.len) ) {
+ if (!case_diffb(smtptext.s + i + 4,"AUTH",4)) {
+ if (case_starts(smtptext.s + i + 9,"CRAM"))
if (mailfrom_cram() >= 0) return;
- if (case_starts(smtptext.s + i,"LOGIN"))
+ if (case_starts(smtptext.s + i + 9,"LOGIN"))
if (mailfrom_login() >= 0) return;
- if (case_starts(smtptext.s + i,"PLAIN"))
+ if (case_starts(smtptext.s + i + 9,"PLAIN"))
if (mailfrom_plain() >= 0) return;
}
+ }
+
err_authprot();
mailfrom();
}
@@ -899,7 +905,7 @@ void smtp()
if (code >= 400) quit("Z"," failed on DATA command");
buffer_putflush(&bo,header.s,header.len);
-
+
blast();
code = smtpcode();
flagcritical = 0;