summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-11-10 00:24:54 +0000
committerJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-11-10 00:24:54 +0000
commit7aa96057441816d35d0ce58c1550241f81d6bfba (patch)
treecf324bfbaee78919c461a9df82ba384661b24eae
parent18d0833c594f70a1d3a9c405e647f7a1b6f83a5f (diff)
Check for extension keywords on final multiline reply. Skip the
check for states other than CLIENT_EHLO. Verify response is not shorter than 3 chars. From Nils Frohberg ok gilles@
-rw-r--r--usr.sbin/smtpd/client.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/usr.sbin/smtpd/client.c b/usr.sbin/smtpd/client.c
index 1158a7a31dd..a34a7247e6d 100644
--- a/usr.sbin/smtpd/client.c
+++ b/usr.sbin/smtpd/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.9 2009/10/25 20:43:29 chl Exp $ */
+/* $OpenBSD: client.c,v 1.10 2009/11/10 00:24:53 jacekm Exp $ */
/*
* Copyright (c) 2009 Jacek Masiulaniec <jacekm@dobremiasto.net>
@@ -875,17 +875,22 @@ client_getln(struct smtp_client *sp)
if (sp->verbose)
fprintf(sp->verbose, "<<< %s\n", ln);
- if (strlen(ln) == 3 || ln[3] == ' ')
+ if (strlen(ln) == 3)
break;
- else if (ln[3] != '-') {
- cause = "150 garbled multiline reply";
+ else if (strlen(ln) < 4 || (ln[3] != ' ' && ln[3] != '-')) {
+ cause = "150 garbled smtp reply";
goto done;
}
- if (strcmp(ln + 4, "STARTTLS") == 0)
- sp->exts[CLIENT_EXT_STARTTLS].have = 1;
- if (strncmp(ln + 4, "AUTH", 4) == 0)
- sp->exts[CLIENT_EXT_AUTH].have = 1;
+ if (sp->state == CLIENT_EHLO) {
+ if (strcmp(ln + 4, "STARTTLS") == 0)
+ sp->exts[CLIENT_EXT_STARTTLS].have = 1;
+ else if (strncmp(ln + 4, "AUTH", 4) == 0)
+ sp->exts[CLIENT_EXT_AUTH].have = 1;
+ }
+
+ if (ln[3] == ' ')
+ break;
}
/* validate reply code */