diff options
author | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2009-09-21 20:35:27 +0000 |
---|---|---|
committer | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2009-09-21 20:35:27 +0000 |
commit | 71a87c745f33a23035edcd8b8ab2192b86f2bbbe (patch) | |
tree | 490106449a1dd4d0a92ed2506d9c26d299c93ed9 /usr.sbin | |
parent | c4ccc49f047facec76d0028af2cc305ad02b1195 (diff) |
Expand "&" in the name part of gecos similarly to how sendmail and finger
expand it. Based on a diff from landry@, thanks!
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/enqueue.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/usr.sbin/smtpd/enqueue.c b/usr.sbin/smtpd/enqueue.c index 3b0fc046d68..e683354297b 100644 --- a/usr.sbin/smtpd/enqueue.c +++ b/usr.sbin/smtpd/enqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enqueue.c,v 1.23 2009/09/18 00:04:26 jacekm Exp $ */ +/* $OpenBSD: enqueue.c,v 1.24 2009/09/21 20:35:26 jacekm Exp $ */ /* * Copyright (c) 2005 Henning Brauer <henning@bulabula.org> @@ -290,13 +290,22 @@ build_from(char *fake_from, struct passwd *pw) } if (msg.fromname == NULL && fake_from == NULL && pw != NULL) { - size_t len; + int len, apos; len = strcspn(pw->pw_gecos, ","); - len++; /* null termination */ - if ((msg.fromname = malloc(len)) == NULL) - err(1, NULL); - strlcpy(msg.fromname, pw->pw_gecos, len); + if ((p = memchr(pw->pw_gecos, '&', len))) { + apos = p - pw->pw_gecos; + if (asprintf(&msg.fromname, "%.*s%s%.*s", + apos, pw->pw_gecos, + pw->pw_name, + len - apos - 1, p + 1) == -1) + err(1, NULL); + msg.fromname[apos] = toupper(msg.fromname[apos]); + } else { + if (asprintf(&msg.fromname, "%.*s", len, + pw->pw_gecos) == -1) + err(1, NULL); + } } } |