From owner-svn-src-all@freebsd.org Tue May 5 18:06:32 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A221613F7BC; Tue, 5 May 2020 18:06:32 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49GnjN3q4Xz4Kqy; Tue, 5 May 2020 18:06:32 +0000 (UTC) (envelope-from cem@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7E40C1A019; Tue, 5 May 2020 18:06:32 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 045I6WvK083930; Tue, 5 May 2020 18:06:32 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 045I6WCC083929; Tue, 5 May 2020 18:06:32 GMT (envelope-from cem@FreeBSD.org) Message-Id: <202005051806.045I6WCC083929@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Tue, 5 May 2020 18:06:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r360665 - head/bin/ls X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/bin/ls X-SVN-Commit-Revision: 360665 X-SVN-Commit-Repository: base 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.30 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: Tue, 05 May 2020 18:06:32 -0000 Author: cem Date: Tue May 5 18:06:32 2020 New Revision: 360665 URL: https://svnweb.freebsd.org/changeset/base/360665 Log: ls(1): Fix trivial SEGV due to NULL deref in OOM path Reported by: Anton Rang Sponsored by: Dell EMC Isilon Modified: head/bin/ls/ls.c Modified: head/bin/ls/ls.c ============================================================================== --- head/bin/ls/ls.c Tue May 5 17:57:04 2020 (r360664) +++ head/bin/ls/ls.c Tue May 5 18:06:32 2020 (r360665) @@ -838,7 +838,21 @@ display(const FTSENT *p, FTSENT *list, int options) group = ngroup; } else { user = user_from_uid(sp->st_uid, 0); + /* + * user_from_uid(..., 0) only returns + * NULL in OOM conditions. We could + * format the uid here, but (1) in + * general ls(1) exits on OOM, and (2) + * there is another allocation/exit + * path directly below, which will + * likely exit anyway. + */ + if (user == NULL) + err(1, "user_from_uid"); group = group_from_gid(sp->st_gid, 0); + /* Ditto. */ + if (group == NULL) + err(1, "group_from_gid"); } if ((ulen = strlen(user)) > maxuser) maxuser = ulen;