Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Feb 2015 19:51:35 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r278363 - head/lib/libc/gen
Message-ID:  <201502071951.t17JpZ6O076707@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Sat Feb  7 19:51:34 2015
New Revision: 278363
URL: https://svnweb.freebsd.org/changeset/base/278363

Log:
  Protect uninitialized scalar variable from being accessed
  
  In a couple of cases a variable "stayopen" can be checked
  unitialized. This is of no danger as the complementary
  condition is false but prevent the access by switching
  the checks.
  
  CID:	1018729
  CID:	1018732

Modified:
  head/lib/libc/gen/getgrent.c
  head/lib/libc/gen/getpwent.c

Modified: head/lib/libc/gen/getgrent.c
==============================================================================
--- head/lib/libc/gen/getgrent.c	Sat Feb  7 17:53:47 2015	(r278362)
+++ head/lib/libc/gen/getgrent.c	Sat Feb  7 19:51:34 2015	(r278363)
@@ -896,7 +896,7 @@ files_group(void *retval, void *mdata, v
 			break;
 		pos = ftello(st->fp);
 	}
-	if (!stayopen && st->fp != NULL) {
+	if (st->fp != NULL && !stayopen) {
 		fclose(st->fp);
 		st->fp = NULL;
 	}

Modified: head/lib/libc/gen/getpwent.c
==============================================================================
--- head/lib/libc/gen/getpwent.c	Sat Feb  7 17:53:47 2015	(r278362)
+++ head/lib/libc/gen/getpwent.c	Sat Feb  7 19:51:34 2015	(r278363)
@@ -921,7 +921,7 @@ files_passwd(void *retval, void *mdata, 
 		    errnop);
 	} while (how == nss_lt_all && !(rv & NS_TERMINATE));
 fin:
-	if (!stayopen && st->db != NULL) {
+	if (st->db != NULL && !stayopen) {
 		(void)st->db->close(st->db);
 		st->db = NULL;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502071951.t17JpZ6O076707>