diff options
author | doug <doug@cvs.openbsd.org> | 2014-08-23 15:29:56 +0000 |
---|---|---|
committer | doug <doug@cvs.openbsd.org> | 2014-08-23 15:29:56 +0000 |
commit | ae17dc64299220e105dd27da687535ea3c157aed (patch) | |
tree | 5cf9a475e7d5cc2de88596e53644a8f67722d30a | |
parent | ba18edf0cdf991e84b9f077f066b9d650efe66aa (diff) |
close fd when fdopen fails
ok yasuoka@
-rw-r--r-- | usr.sbin/npppd/npppd/privsep.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.sbin/npppd/npppd/privsep.c b/usr.sbin/npppd/npppd/privsep.c index 434c857cac7..a1e05616e50 100644 --- a/usr.sbin/npppd/npppd/privsep.c +++ b/usr.sbin/npppd/npppd/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.14 2014/07/18 13:16:22 yasuoka Exp $ */ +/* $OpenBSD: privsep.c,v 1.15 2014/08/23 15:29:55 doug Exp $ */ /* * Copyright (c) 2010 Yasuoka Masahiko <yasuoka@openbsd.org> @@ -282,11 +282,16 @@ FILE * priv_fopen(const char *path) { int f; + FILE *fp; if ((f = priv_open(path, O_RDONLY, 0600)) < 0) return (NULL); - return fdopen(f, "r"); + if ((fp = fdopen(f, "r")) == NULL) { + close(f); + return (NULL); + } else + return (fp); } int |