From: doug Date: Sat, 23 Aug 2014 15:29:55 +0000 (+0000) Subject: close fd when fdopen fails X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a67e5f572809306e7477edb6d18fb958e42974cb;p=openbsd close fd when fdopen fails ok yasuoka@ --- 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 @@ -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