From owner-svn-src-head@freebsd.org Tue Oct 3 00:53:12 2017 Return-Path: Delivered-To: svn-src-head@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 ED61AE2BA69; Tue, 3 Oct 2017 00:53:12 +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 mx1.freebsd.org (Postfix) with ESMTPS id B9F3581AB9; Tue, 3 Oct 2017 00:53:12 +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 v930rBmu036670; Tue, 3 Oct 2017 00:53:11 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v930rBq6036668; Tue, 3 Oct 2017 00:53:11 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201710030053.v930rBq6036668@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Tue, 3 Oct 2017 00:53:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324229 - in head: sbin/init usr.bin/lock X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head: sbin/init usr.bin/lock X-SVN-Commit-Revision: 324229 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Oct 2017 00:53:13 -0000 Author: cem Date: Tue Oct 3 00:53:11 2017 New Revision: 324229 URL: https://svnweb.freebsd.org/changeset/base/324229 Log: Correct sense of crypt(3) NULL checks in init(8) and lock(1) In r231994, an attempt was made to fix crypt(3) failure returns (NULL). However, instead of treating crypt(3) failure as authentication failure, some of the changes treated crypt(3) failure as authentication success. This is wrong. r324225 fixed this for ppp, which also inspired this review. The other changes in the 231994 revision were audited for correctness and look ok. Reviewed by: jhb Security: yes Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D12571 Modified: head/sbin/init/init.c head/usr.bin/lock/lock.c Modified: head/sbin/init/init.c ============================================================================== --- head/sbin/init/init.c Mon Oct 2 23:31:11 2017 (r324228) +++ head/sbin/init/init.c Tue Oct 3 00:53:11 2017 (r324229) @@ -919,7 +919,7 @@ single_user(void) _exit(0); password = crypt(clear, pp->pw_passwd); bzero(clear, _PASSWORD_LEN); - if (password == NULL || + if (password != NULL && strcmp(password, pp->pw_passwd) == 0) break; warning("single-user login failed\n"); Modified: head/usr.bin/lock/lock.c ============================================================================== --- head/usr.bin/lock/lock.c Mon Oct 2 23:31:11 2017 (r324228) +++ head/usr.bin/lock/lock.c Tue Oct 3 00:53:11 2017 (r324229) @@ -223,7 +223,7 @@ main(int argc, char **argv) if (usemine) { s[strlen(s) - 1] = '\0'; cryptpw = crypt(s, mypw); - if (cryptpw == NULL || !strcmp(mypw, cryptpw)) + if (cryptpw != NULL && !strcmp(mypw, cryptpw)) break; } else if (!strcmp(s, s1))