From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#36834: 27.0.50; [PATCH] password-cache.el: confuses key absence with nil password Date: Sat, 10 Aug 2019 05:14:22 -0400 Message-ID: References: <875znltof0.fsf@telefonica.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="125815"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 36834@debbugs.gnu.org To: =?UTF-8?Q?=C3=93scar?= Fuentes Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 10 11:15:09 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hwNSv-000Wa4-IT for geb-bug-gnu-emacs@m.gmane.org; Sat, 10 Aug 2019 11:15:09 +0200 Original-Received: from localhost ([::1]:35516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hwNSu-0004F2-4u for geb-bug-gnu-emacs@m.gmane.org; Sat, 10 Aug 2019 05:15:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34253) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hwNSp-0004Eu-U0 for bug-gnu-emacs@gnu.org; Sat, 10 Aug 2019 05:15:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hwNSo-0008OJ-T9 for bug-gnu-emacs@gnu.org; Sat, 10 Aug 2019 05:15:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34638) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hwNSo-0008NW-PE for bug-gnu-emacs@gnu.org; Sat, 10 Aug 2019 05:15:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hwNSo-0006QU-9R for bug-gnu-emacs@gnu.org; Sat, 10 Aug 2019 05:15:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Aug 2019 09:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36834 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 36834-submit@debbugs.gnu.org id=B36834.156542847424653 (code B ref 36834); Sat, 10 Aug 2019 09:15:02 +0000 Original-Received: (at 36834) by debbugs.gnu.org; 10 Aug 2019 09:14:34 +0000 Original-Received: from localhost ([127.0.0.1]:43459 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hwNSL-0006PZ-T9 for submit@debbugs.gnu.org; Sat, 10 Aug 2019 05:14:34 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:27508) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hwNSK-0006PP-EM for 36834@debbugs.gnu.org; Sat, 10 Aug 2019 05:14:32 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id E5D1E103310; Sat, 10 Aug 2019 05:14:26 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 61CE91032F4; Sat, 10 Aug 2019 05:14:25 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1565428465; bh=r/jGDIKg0XNebnQ53PyzV/pLAWI3MfbDGsVFZhWsq58=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=kV+htCZ5kD5Ofe2qVrZhmamCO9hWpw03nbNBX/TZpf352FUq79CupnEQwveUe28L8 3Psocvyg5fFHN6ch3cYpMIus9IgBkrRgPCWXRxe++g/JTSeUFOfjU97XIa14OlpFwl whhEA2oTnveC3QRxRCgeMIqeOpmjisq6KXRB7wxL63vlJ+7w2Zkk4iKINFG19FwF93 2T6cWy5a3tDqkg8SZYqB2X2lOChTzXLOVIrRPwwYBpaF1FFAazm6/DlG6eklJ3ik0k 3bRM/f87hcAIL0ge16Gsf4ADlofX55B314wq/+a8DdZPmWUzA37AK7ldf0L7Y36cjI Tv+8yAn/jko5g== Original-Received: from alfajor (dyn.83-228-179-131.dsl.vtx.ch [83.228.179.131]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id AB340120A4C; Sat, 10 Aug 2019 05:14:24 -0400 (EDT) In-Reply-To: <875znltof0.fsf@telefonica.net> ("=?UTF-8?Q?=C3=93scar?= Fuentes"'s message of "Mon, 29 Jul 2019 07:12:03 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:164831 Archived-At: > So I propose this patch: > > diff --git a/lisp/password-cache.el b/lisp/password-cache.el > index 5a09ae4859..6009fb491e 100644 > --- a/lisp/password-cache.el > +++ b/lisp/password-cache.el > @@ -81,7 +81,8 @@ password-in-cache-p > "Check if KEY is in the cache." > (and password-cache > key > - (gethash key password-data))) > + (not (eq (gethash key password-data 'password-cache-no-data) > + 'password-cache-no-data)))) > > (defun password-read (prompt &optional key) > "Read password, for use with KEY, from user, or from cache if wanted. > @@ -125,7 +126,9 @@ password-cache-remove > (defun password-cache-add (key password) > "Add password to cache. > The password is removed by a timer after `password-cache-expiry' seconds." > - (when (and password-cache-expiry (null (gethash key password-data))) > + (when (and password-cache-expiry > + (eq (gethash key password-data 'password-cache-no-data) > + 'password-cache-no-data)) > (run-at-time password-cache-expiry nil > #'password-cache-remove > key)) Looks good to me, thanks. > On another topic, before a cache entry is removed we try to overwrite > the stored password (see password-cache-remove). However, the same > change did this: > > > (defun password-reset () > "Clear the password cache." > (interactive) > - (fillarray password-data 0)) > + (clrhash password-data)) Obarrays are just arrays of symbols (i.e. arrays of pointers to symbol objects), so (fillarray password-data 0) does not overwrite the passwords stored in the symbols, it just overwrites the pointers to those symbols. (clrhash password-data) has basically the same effect. Stefan