Don't close an uninitialized descriptor. [1]

Add a sanity check for the validity of the passed fd.

PR:		kern/139080 [1]
Submitted by:	Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua> [1]
Reviewed by:	pjd (briefly)
Approved by:	cperciva
MFC after:	1 week
This commit is contained in:
eadler 2012-06-20 06:38:41 +00:00
parent 8cc89048d4
commit 558058eeda

View File

@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <sys/un.h>
#include <netdb.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <paths.h>
@ -413,8 +414,11 @@ void
closelog(void)
{
THREAD_LOCK();
(void)_close(LogFile);
LogFile = -1;
assert(LogFile >= -1);
if (LogFile != -1) {
(void)_close(LogFile);
LogFile = -1;
}
LogTag = NULL;
status = NOCONN;
THREAD_UNLOCK();