summaryrefslogtreecommitdiff
path: root/src/qmail-remote.c
diff options
context:
space:
mode:
authorJannis Hoffmann <jannis@fehcom.de>2024-07-18 15:15:18 +0200
committerJannis Hoffmann <jannis@fehcom.de>2024-07-18 15:15:18 +0200
commit7b4d3ab22988d021d5f12b81aec746f7e486fa52 (patch)
tree651e78e316411a39baadadb1cfaca450e1351c7f /src/qmail-remote.c
parent25f74781424d5e13f0211c08cce8c2a1d60b9aec (diff)
update to 4.3.09
Diffstat (limited to 'src/qmail-remote.c')
-rw-r--r--src/qmail-remote.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/qmail-remote.c b/src/qmail-remote.c
index fc90cd4..a6ef155 100644
--- a/src/qmail-remote.c
+++ b/src/qmail-remote.c
@@ -474,14 +474,14 @@ void tls_init()
temp_tlserr();
}
-int starttls_peer()
+int ehlo_starttls()
{
int i = 0;
- while ((i += str_chr(smtptext.s + i,'\n') + 1) &&
- (i + 8 < smtptext.len) ) {
- if (!str_diffn(smtptext.s + i + 4,"STARTTLS",8)) return 1;
- }
+ do {
+ if (case_startb(smtptext.s + i + 4,8,"STARTTLS")) return 1;
+ } while ((i += str_chr(smtptext.s + i,'\n') + 1) &&
+ (i < smtptext.len - 12));
return 0;
}
@@ -595,14 +595,14 @@ int utf8received()
unsigned long code;
int flagsize = 0;
-int smtp_size()
+int ehlo_size()
{
- int i;
+ int i = 0;
- while ((i += str_chr(smtptext.s + i,'\n') + 1) &&
- (i + 8 <= smtptext.len) ) {
- if (!str_diffn(smtptext.s + i + 4,"SIZE",4)) return 1;
- }
+ do {
+ if (case_startb(smtptext.s + i + 4,4,"SIZE")) return 1;
+ } while ((i += str_chr(smtptext.s + i,'\n') + 1) &&
+ (i < smtptext.len - 8));
return 0;;
}
@@ -625,7 +625,7 @@ void smtp_greeting()
if (code >= 500) quit("DConnected to "," but my name was rejected");
if (code != 250) quit("ZConnected to "," but my name was rejected");
}
- flagsize = smtp_size();
+ flagsize = ehlo_size();
}
void smtp_starttls()
@@ -813,21 +813,22 @@ int mailfrom_cram()
return 0;
}
-void smtp_auth()
+void ehlo_auth()
{
- int i;
+ int i = 0;
- 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 + 9,"LOGIN"))
- if (mailfrom_login() >= 0) return;
- if (case_starts(smtptext.s + i + 9,"PLAIN"))
- if (mailfrom_plain() >= 0) return;
- }
- }
+ do {
+ if (case_startb(smtptext.s + i + 4,4,"AUTH"))
+ for (i = 4; i < smtptext.len - 5; ++i) {
+ if (case_startb(smtptext.s + i,4,"CRAM"))
+ if (mailfrom_cram() >= 0) return;
+ if (case_startb(smtptext.s + i,5,"LOGIN"))
+ if (mailfrom_login() >= 0) return;
+ if (case_startb(smtptext.s + i,5,"PLAIN"))
+ if (mailfrom_plain() >= 0) return;
+ }
+ } while ((i += str_chr(smtptext.s + i,'\n') + 1) &&
+ (i < smtptext.len - 12));
err_authprot();
mailfrom();
@@ -854,7 +855,7 @@ void smtp()
smtp_greeting();
if (flagtls > 0 && flagtls < 10) { /* STARTTLS */
- if (starttls_peer())
+ if (ehlo_starttls())
smtp_starttls();
else if (flagtls > 3 && flagtls != 9) {
if (!stralloc_0(&host)) temp_nomem();
@@ -862,7 +863,7 @@ void smtp()
}
}
if (user.len && pass.len) /* AUTH */
- smtp_auth();
+ ehlo_auth();
else
mailfrom(); /* Mail From */
@@ -1226,8 +1227,8 @@ int main(int argc,char **argv)
qmtpsend = 1; port = PORT_QMTP;
break;
} /* default smtproutes */
- if ((relayhost = constmap(&mapsmtproutes,host.s + i,host.len - i)))
- break;
+ if ((relayhost = constmap(&mapsmtproutes,host.s + i,host.len - i)))
+ break;
}
}
if (relayhost && !*relayhost) relayhost = 0;