aboutsummaryrefslogtreecommitdiff
path: root/mail/opensmtpd
diff options
context:
space:
mode:
authorAshish SHUKLA <ashish@FreeBSD.org>2015-08-16 21:54:15 +0000
committerAshish SHUKLA <ashish@FreeBSD.org>2015-08-16 21:54:15 +0000
commit5fa1298b546bfa392431efc3247c870fa9db95e2 (patch)
treea7af2f913373a7a3ee256b7ab9dd0dbce43ea93a /mail/opensmtpd
parent4461ed4d6e2e4ee005976ff9661828301662c6b6 (diff)
downloadports-5fa1298b546bfa392431efc3247c870fa9db95e2.tar.gz
ports-5fa1298b546bfa392431efc3247c870fa9db95e2.zip
- Add a patch to handle long usernames during SMTP authentication,
e.g. often username exceeds the limit when it contains @host.name part. Reported by: gahr (via private email) Obtained from: Philipp Takacs <philipp@bureaucracy.de> (via IRC)
Notes
Notes: svn path=/head/; revision=394424
Diffstat (limited to 'mail/opensmtpd')
-rw-r--r--mail/opensmtpd/Makefile1
-rw-r--r--mail/opensmtpd/files/patch-usernamelen61
2 files changed, 62 insertions, 0 deletions
diff --git a/mail/opensmtpd/Makefile b/mail/opensmtpd/Makefile
index d63bdfd3b54e..6e453a35437a 100644
--- a/mail/opensmtpd/Makefile
+++ b/mail/opensmtpd/Makefile
@@ -3,6 +3,7 @@
PORTNAME= opensmtpd
PORTVERSION= 5.7.1
+PORTREVISION= 1
PORTEPOCH= 1
CATEGORIES= mail
MASTER_SITES= http://www.opensmtpd.org/archives/ \
diff --git a/mail/opensmtpd/files/patch-usernamelen b/mail/opensmtpd/files/patch-usernamelen
new file mode 100644
index 000000000000..269c6c86cef0
--- /dev/null
+++ b/mail/opensmtpd/files/patch-usernamelen
@@ -0,0 +1,61 @@
+diff --git a/smtpd/smtp_session.c b/smtpd/smtp_session.c
+index 3a0ca2a..404ee50 100644
+--- smtpd/smtp_session.c
++++ smtpd/smtp_session.c
+@@ -84,6 +84,7 @@ enum session_flags {
+ SF_BADINPUT = 0x0080,
+ SF_FILTERCONN = 0x0100,
+ SF_FILTERDATA = 0x0200,
++ SF_USERTOLONG = 0x0400,
+ };
+
+ enum message_flags {
+@@ -133,7 +134,7 @@ struct smtp_session {
+
+ char helo[LINE_MAX];
+ char cmd[LINE_MAX];
+- char username[LOGIN_NAME_MAX];
++ char username[LOGIN_NAME_MAX+HOST_NAME_MAX+1];
+
+ struct envelope evp;
+
+@@ -990,6 +991,15 @@ smtp_session_imsg(struct mproc *p, struct imsg *imsg)
+
+ s = tree_xpop(&wait_parent_auth, reqid);
+ strnvis(user, s->username, sizeof user, VIS_WHITE | VIS_SAFE);
++
++ if (s->flags & SF_USERTOLONG) {
++ log_info("smtp-in: sesson %016"PRIx64
++ ": auth failed because username to long",
++ s->id);
++ s->flags &= (~SF_USERTOLONG);
++ success = LKA_PERMFAIL;
++ }
++
+ if (success == LKA_OK) {
+ log_info("smtp-in: session %016"PRIx64
+ ": authentication successful for user %s ",
+@@ -1929,7 +1939,7 @@ smtp_rfc4954_auth_plain(struct smtp_session *s, char *arg)
+ user++; /* skip NUL */
+ if (strlcpy(s->username, user, sizeof(s->username))
+ >= sizeof(s->username))
+- goto abort;
++ s->flags |= SF_USERTOLONG;
+
+ pass = memchr(user, '\0', len - (user - buf));
+ if (pass == NULL || pass >= buf + len - 2)
+@@ -1969,9 +1979,12 @@ smtp_rfc4954_auth_login(struct smtp_session *s, char *arg)
+
+ case STATE_AUTH_USERNAME:
+ memset(s->username, 0, sizeof(s->username));
+- if (base64_decode(arg, (unsigned char *)s->username,
+- sizeof(s->username) - 1) == -1)
++ if (base64_decode(arg, (unsigned char *)buf,
++ sizeof(buf) - 1) == -1)
+ goto abort;
++ if (strlcpy(s->username, buf, sizeof(s->username))
++ >= sizeof(s->username))
++ s->flags |= SF_USERTOLONG;
+
+ smtp_enter_state(s, STATE_AUTH_PASSWORD);
+ smtp_reply(s, "334 UGFzc3dvcmQ6");