From owner-svn-src-all@freebsd.org Wed Mar 22 18:12:50 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2A02CD179B2; Wed, 22 Mar 2017 18:12:50 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 EACF71D8C; Wed, 22 Mar 2017 18:12:49 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2MICnt1040714; Wed, 22 Mar 2017 18:12:49 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2MICncq040713; Wed, 22 Mar 2017 18:12:49 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201703221812.v2MICncq040713@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Wed, 22 Mar 2017 18:12:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r315725 - stable/11/lib/libc/gen X-SVN-Group: stable-11 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.23 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: Wed, 22 Mar 2017 18:12:50 -0000 Author: pfg Date: Wed Mar 22 18:12:48 2017 New Revision: 315725 URL: https://svnweb.freebsd.org/changeset/base/315725 Log: MFC r315720 (from cem@) scandir: Fix NULL dereference, uninitialized value use in error case This bug was introduced in r315095. Given that it obviously is a bug and we can't afford to have such creatures in libc, do an early merge, Reported by: Coverity CIDs: 1329566, 1372625 Sponsored by: Dell EMC Isilon Modified: stable/11/lib/libc/gen/scandir.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/gen/scandir.c ============================================================================== --- stable/11/lib/libc/gen/scandir.c Wed Mar 22 17:56:46 2017 (r315724) +++ stable/11/lib/libc/gen/scandir.c Wed Mar 22 18:12:48 2017 (r315725) @@ -89,12 +89,12 @@ scandir(const char *dirname, struct dire if ((dirp = opendir(dirname)) == NULL) return(-1); + numitems = 0; arraysz = 32; /* initial estimate of the array size */ names = (struct dirent **)malloc(arraysz * sizeof(struct dirent *)); if (names == NULL) goto fail; - numitems = 0; while ((d = readdir(dirp)) != NULL) { if (select != NULL && !SELECT(d)) continue; /* just selected names */