From owner-svn-src-all@FreeBSD.ORG Sun Feb 15 16:50:22 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 5021FE33; Sun, 15 Feb 2015 16:50:22 +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 3C780CBD; Sun, 15 Feb 2015 16:50:22 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1FGoMwx032122; Sun, 15 Feb 2015 16:50:22 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1FGoLTi032120; Sun, 15 Feb 2015 16:50:21 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201502151650.t1FGoLTi032120@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 15 Feb 2015 16:50:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278804 - 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: Sun, 15 Feb 2015 16:50:22 -0000 Author: pfg Date: Sun Feb 15 16:50:21 2015 New Revision: 278804 URL: https://svnweb.freebsd.org/changeset/base/278804 Log: More tidy-ups on uninitialized scalar variable As a followup to r278363, there is one more case where stayopen can be accessed uninitialized, but even after swapping arguments, access is possible in some other cases so prevent it completely by initializing stayopen. 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 Sun Feb 15 14:31:50 2015 (r278803) +++ head/lib/libc/gen/getgrent.c Sun Feb 15 16:50:21 2015 (r278804) @@ -1303,7 +1303,7 @@ compat_group(void *retval, void *mdata, void *discard; size_t bufsize, linesize; off_t pos; - int rv, stayopen, *errnop; + int rv, stayopen = 0, *errnop; #define set_lookup_type(x, y) do { \ int i; \ @@ -1450,7 +1450,7 @@ docompat: pos = ftello(st->fp); } fin: - 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 Sun Feb 15 14:31:50 2015 (r278803) +++ head/lib/libc/gen/getpwent.c Sun Feb 15 16:50:21 2015 (r278804) @@ -815,7 +815,7 @@ files_passwd(void *retval, void *mdata, size_t bufsize, namesize; uid_t uid; uint32_t store; - int rv, stayopen, *errnop; + int rv, stayopen = 0, *errnop; name = NULL; uid = (uid_t)-1;