svn commit: r237286 - head/lib/libc/gen
Eitan Adler
eadler at FreeBSD.org
Wed Jun 20 06:38:42 UTC 2012
Author: eadler
Date: Wed Jun 20 06:38:41 2012
New Revision: 237286
URL: http://svn.freebsd.org/changeset/base/237286
Log:
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 at comsys.ntu-kpi.kiev.ua> [1]
Reviewed by: pjd (briefly)
Approved by: cperciva
MFC after: 1 week
Modified:
head/lib/libc/gen/syslog.c
Modified: head/lib/libc/gen/syslog.c
==============================================================================
--- head/lib/libc/gen/syslog.c Wed Jun 20 04:11:34 2012 (r237285)
+++ head/lib/libc/gen/syslog.c Wed Jun 20 06:38:41 2012 (r237286)
@@ -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();
More information about the svn-src-all
mailing list