From owner-svn-src-all@FreeBSD.ORG Sat Feb 7 19:51:36 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6DEB55F8; Sat, 7 Feb 2015 19:51:36 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 597C1FB5; Sat, 7 Feb 2015 19:51:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t17Jpa30076710; Sat, 7 Feb 2015 19:51:36 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t17JpZ6O076707; Sat, 7 Feb 2015 19:51:35 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201502071951.t17JpZ6O076707@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sat, 7 Feb 2015 19:51:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278363 - head/lib/libc/gen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Feb 2015 19:51:36 -0000 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; }