-/* $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>
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