diff options
author | 2009-03-01 15:06:23 +0000 | |
---|---|---|
committer | 2009-03-01 15:06:23 +0000 | |
commit | 3acf990a5d4e0e221808a5b66e9617fef2705839 (patch) | |
tree | d5148a504954b0a5f9dd82ab4e08c0dd4975997f | |
parent | fix double space in synopsis and usage. (diff) | |
download | wireguard-openbsd-3acf990a5d4e0e221808a5b66e9617fef2705839.tar.xz wireguard-openbsd-3acf990a5d4e0e221808a5b66e9617fef2705839.zip |
fix possible NULL dereference when getpwnam fails; ok gilles@
-rw-r--r-- | usr.sbin/smtpd/smtpd.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index 920308be39d..5f4cae3a21d 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.35 2009/03/01 13:08:47 jacekm Exp $ */ +/* $OpenBSD: smtpd.c,v 1.36 2009/03/01 15:06:23 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -319,9 +319,17 @@ parent_dispatch_mda(int fd, short event, void *p) pw_name = SMTPD_USER; } + errno = 0; pw = safe_getpwnam(pw_name); - if (pw == NULL) - batchp->message.status |= S_MESSAGE_PERMFAILURE; + if (pw == NULL) { + if (errno) + batchp->message.status |= S_MESSAGE_TEMPFAILURE; + else + batchp->message.status |= S_MESSAGE_PERMFAILURE; + imsg_compose(ibuf, IMSG_MDA_MAILBOX_FILE, 0, 0, + -1, batchp, sizeof(struct batch)); + break; + } if (setegid(pw->pw_gid) || seteuid(pw->pw_uid)) fatal("privdrop failed"); |