summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/lka_session.c
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2012-07-29 17:21:44 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2012-07-29 17:21:44 +0000
commit372f34631b1ff121b61a45ea95897d3caf8e470d (patch)
treec6e4cde8818fe20fd2b8f819c0a4745eb028c165 /usr.sbin/smtpd/lka_session.c
parent04da5a8af0f210ddec600baed1f0ddcb32e36172 (diff)
- introduce xlowercase() and allow lowercase() to fail gracefully
- replace all calls to lowercase() with calls to xlowercase() - in the format string expansion, lowercase() all formats we will have to reassess all calls to xlowercase() even though it has never triggered as far as I know, we can probably gracefully fail some of them. right now we're just keeping former behaviour. this commit fixes issue reported by Hugo Osvaldo Barrera where a %u format could lead to a delivery failure (ie: GILLES@openbsd.org should be expanded to gilles, not GILLES ... only for local deliveries). ok chl@ on the idea, ok eric@ on the diff
Diffstat (limited to 'usr.sbin/smtpd/lka_session.c')
-rw-r--r--usr.sbin/smtpd/lka_session.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.sbin/smtpd/lka_session.c b/usr.sbin/smtpd/lka_session.c
index b0b1423ad21..f0eec8e037e 100644
--- a/usr.sbin/smtpd/lka_session.c
+++ b/usr.sbin/smtpd/lka_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka_session.c,v 1.18 2012/07/29 16:33:01 eric Exp $ */
+/* $OpenBSD: lka_session.c,v 1.19 2012/07/29 17:21:43 gilles Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -94,7 +94,7 @@ lka_session_envelope_expand(struct lka_session *lks, struct envelope *ep)
user = ep->dest.user;
else
user = ep->agent.mda.to.user;
- lowercase(username, user, sizeof(username));
+ xlowercase(username, user, sizeof(username));
/* gilles+hackers@ -> gilles@ */
if ((tag = strchr(username, '+')) != NULL) {
@@ -505,6 +505,7 @@ lka_session_expand_format(char *buf, size_t len, struct envelope *ep)
struct user_backend *ub;
struct mta_user u;
char lbuffer[MAX_RULEBUFFER_LEN];
+ char tmpbuf[MAX_RULEBUFFER_LEN];
bzero(lbuffer, sizeof (lbuffer));
pbuf = lbuffer;
@@ -580,6 +581,10 @@ lka_session_expand_format(char *buf, size_t len, struct envelope *ep)
goto copy;
}
+ if (! lowercase(tmpbuf, string, sizeof tmpbuf))
+ return 0;
+ string = tmpbuf;
+
if (digit == 1) {
size_t idx = *(tmp - 1) - '0';