diff options
author | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2009-03-01 15:06:24 +0000 |
---|---|---|
committer | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2009-03-01 15:06:24 +0000 |
commit | 0ef108c216367679e810f197c9f98722f63dde4b (patch) | |
tree | 5d8730ea51eb99664c8981115adc52f650f4d11c /usr.sbin/smtpd | |
parent | 2d51fb854a1210ac8af495b233c802a420d97f37 (diff) |
fix possible NULL dereference when getpwnam fails; ok gilles@
Diffstat (limited to 'usr.sbin/smtpd')
-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"); |