GNU bug report logs -
#22027
25.1.50; read-passwd fail to return default password
Previous Next
Reported by: Tino Calancha <f92capac <at> gmail.com>
Date: Fri, 27 Nov 2015 09:51:02 UTC
Severity: normal
Tags: fixed, patch
Found in version 25.1.50
Fixed in version 26.1
Done: npostavs <at> users.sourceforge.net
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 22027 in the body.
You can then email your comments to 22027 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#22027
; Package
emacs
.
(Fri, 27 Nov 2015 09:51:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Tino Calancha <f92capac <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 27 Nov 2015 09:51:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
* lisp/subr.el (read-passwd):
read-passwd returns string consisting of (length password)
NULL characters, when:
*) first argument non-nil,
*) second argument string != "",
*) user accepts the default password.
emacs -Q:
(read-passwd "pass: " t "my-pass") RET RET
"--1468197610-674703064-1448617983=:26866
Content-Type: text/plain; charset=US-ASCII; name=subr.patch
Content-Transfer-Encoding: BASE64
Content-ID: <alpine.LRH.2.20.1511271853030.26866 <at> calancha-ilc.kek.jp>
Content-Description:
Content-Disposition: attachment; filename=subr.patch
KioqIGxpc3Avc3Vici5lbAkgICAgICAgIDIwMTUtMTEtMTggMTE6MDI6MzMu
NzAzMTMwODUwICswOTAwDQotLS0gbGlzcC9zdWJyX3BhdGNoZWQuZWwJMjAx
NS0xMS0yNyAxODo0MTowMy41MTAwMzQ3NzkgKzA5MDANCioqKioqKioqKioq
KioqKg0KKioqIDIxMTQsMjEyMSAqKioqDQogICAgICAgICAgICAgICAgICAo
c2Vjb25kIChyZWFkLXBhc3N3ZCAiQ29uZml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AgICht
ZXNzYWdlICJQYXNzd29yZCBub3QgcmVwZWF0ZWQgYWNjdXJhdGVseTsgcGxl
YXNlIHN0YXJ0IG92ZXIiKQ0K
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#22027
; Package
emacs
.
(Fri, 27 Nov 2015 10:14:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 22027 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
[subr.patch (application/octet-stream, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#22027
; Package
emacs
.
(Mon, 09 May 2016 03:24:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 22027 <at> debbugs.gnu.org (full text, mbox):
>*) first argument non-nil,
>*) second argument string != "",
Should read:
*) second argument non-nil,
*) third argument string != "",
In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.30)
of 2016-05-06 built on calancha-pc
Repository revision: 80bea210ff14a64daa1d71765983aa3baa149555
From 1ced98ba1a548749c119a93858f82f1210fe81bc Mon Sep 17 00:00:00 2001
From: Tino Calancha <f92capac <at> gmail.com>
Date: Mon, 9 May 2016 12:01:31 +0900
Subject: [PATCH 1/3] Return uncorrupted default string
* lisp/subr.el (read-passwd): Return DEFAULT when
CONFIRM evaluates non-nil and user inputs the empty string
(Bug#22027).
---
lisp/subr.el | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lisp/subr.el b/lisp/subr.el
index 0fa6404..ef6af1d 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2152,9 +2152,9 @@ read-passwd
(let ((first (read-passwd prompt nil default))
(second (read-passwd "Confirm password: " nil default)))
(if (equal first second)
- (progn
- (and (arrayp second) (clear-string second))
- (setq success first))
+ (prog1
+ (setq success (copy-sequence first))
+ (and (arrayp second) (clear-string second)))
(and (arrayp first) (clear-string first))
(and (arrayp second) (clear-string second))
(message "Password not repeated accurately; please start over")
--
2.8.1
From 7124a681e17e4f33694e9f1c8ccb0261f6a0bf9c Mon Sep 17 00:00:00 2001
From: Tino Calancha <f92capac <at> gmail.com>
Date: Mon, 9 May 2016 12:03:18 +0900
Subject: [PATCH 2/3] * lisp/subr.el (read-passwd): Clear also first password.
---
lisp/subr.el | 1 +
1 file changed, 1 insertion(+)
diff --git a/lisp/subr.el b/lisp/subr.el
index ef6af1d..5c32299 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2154,6 +2154,7 @@ read-passwd
(if (equal first second)
(prog1
(setq success (copy-sequence first))
+ (and (arrayp first) (clear-string first))
(and (arrayp second) (clear-string second)))
(and (arrayp first) (clear-string first))
(and (arrayp second) (clear-string second))
--
2.8.1
From e3aa5b5d30b901c2533538b3a9d0d5bd69493cf0 Mon Sep 17 00:00:00 2001
From: Tino Calancha <f92capac <at> gmail.com>
Date: Mon, 9 May 2016 12:08:02 +0900
Subject: [PATCH 3/3] * lisp/subr.el (read-passwd): Clear non-empty passwords.
---
lisp/subr.el | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lisp/subr.el b/lisp/subr.el
index 5c32299..344c416 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2153,11 +2153,11 @@ read-passwd
(second (read-passwd "Confirm password: " nil default)))
(if (equal first second)
(prog1
- (setq success (copy-sequence first))
- (and (arrayp first) (clear-string first))
- (and (arrayp second) (clear-string second)))
- (and (arrayp first) (clear-string first))
- (and (arrayp second) (clear-string second))
+ (setq success (copy-sequence first))
+ (when (and (arrayp first)
+ (not (string= first "")))
+ (clear-string first)
+ (clear-string second)))
(message "Password not repeated accurately; please start over")
(sit-for 1))))
success)
--
2.8.1
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#22027
; Package
emacs
.
(Sun, 04 Jun 2017 03:50:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 22027 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Tino Calancha <f92capac <at> gmail.com> writes:
> + (setq success (copy-sequence first))
> + (when (and (arrayp first)
> + (not (string= first "")))
> + (clear-string first)
> + (clear-string second)))
I think that is too complicated, how about this instead:
[v1-0001-lisp-subr.el-read-passwd-Don-t-delete-return-valu.patch (text/x-diff, inline)]
From 739ab77ca99a57f10088aa8a9f2c079c1727a071 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sat, 3 Jun 2017 23:41:53 -0400
Subject: [PATCH v1] * lisp/subr.el (read-passwd): Don't delete return value
(Bug#22027).
---
lisp/subr.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/subr.el b/lisp/subr.el
index 9b3e53b70b..76c13a8d23 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2268,7 +2268,7 @@ (defun read-passwd (prompt &optional confirm default)
(second (read-passwd "Confirm password: " nil default)))
(if (equal first second)
(progn
- (and (arrayp second) (clear-string second))
+ (and (arrayp second) (not (eq first second)) (clear-string second))
(setq success first))
(and (arrayp first) (clear-string first))
(and (arrayp second) (clear-string second))
--
2.11.1
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#22027
; Package
emacs
.
(Mon, 05 Jun 2017 00:23:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 22027 <at> debbugs.gnu.org (full text, mbox):
On Sat, 3 Jun 2017, npostavs <at> users.sourceforge.net wrote:
> Tino Calancha <f92capac <at> gmail.com> writes:
>
>> + (setq success (copy-sequence first))
>> + (when (and (arrayp first)
>> + (not (string= first "")))
>> + (clear-string first)
>> + (clear-string second)))
>
> I think that is too complicated, how about this instead:
Yes, your is better. Thank you.
We might add a test as well:
commit eb7fdeefadf08d7a781bee60df45fb045b582930
Author: Tino Calancha <tino.calancha <at> gmail.com>
Date: Mon Jun 5 09:18:55 2017 +0900
* test/lisp/subr-tests.el (subr-tests-bug22027): Add test.
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index c0bfd40f80..81f61220d3 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -28,6 +28,7 @@
;;; Code:
(require 'ert)
+(eval-when-compile (require 'cl-lib))
(ert-deftest let-when-compile ()
;; good case
@@ -316,5 +317,13 @@ subr-tests--this-file
(should-not (method-files 'subr-tests--undefined-generic))
(should-not (method-files 'subr-tests--generic-without-methods)))
+(ert-deftest subr-tests-bug22027 ()
+ "Test for http://debbugs.gnu.org/22027 ."
+ (cl-letf* ((default "foo")
+ ((symbol-function 'read-string)
+ (lambda (&rest args) (mapconcat #'string default ""))))
+ (should (string= default (read-passwd "pass: " 'confirm default)))))
+
+
(provide 'subr-tests)
;;; subr-tests.el ends here
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#22027
; Package
emacs
.
(Mon, 05 Jun 2017 00:40:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 22027 <at> debbugs.gnu.org (full text, mbox):
On Mon, 5 Jun 2017, Tino Calancha wrote:
> We might add a test as well:
but my previous test is wrong: it works before we apply any patch :-)
The following looks right:
commit 3b255c1b04a87442fc8293323f2c827dd44b038a
Author: Tino Calancha <tino.calancha <at> gmail.com>
Date: Mon Jun 5 09:35:29 2017 +0900
* test/lisp/subr-tests.el (subr-tests-bug22027): Add test.
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index c0bfd40f80..54f4ab5d1b 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -28,6 +28,7 @@
;;; Code:
(require 'ert)
+(eval-when-compile (require 'cl-lib))
(ert-deftest let-when-compile ()
;; good case
@@ -316,5 +317,14 @@ subr-tests--this-file
(should-not (method-files 'subr-tests--undefined-generic))
(should-not (method-files 'subr-tests--generic-without-methods)))
+(ert-deftest subr-tests-bug22027 ()
+ "Test for http://debbugs.gnu.org/22027 ."
+ (let ((default "foo") res)
+ (cl-letf (((symbol-function 'read-string)
+ (lambda (_prompt _init _hist def) def)))
+ (setq res (read-passwd "pass: " 'confirm (mapconcat #'string default "")))
+ (should (string= default res)))))
+
+
(provide 'subr-tests)
;;; subr-tests.el ends here
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#22027
; Package
emacs
.
(Mon, 05 Jun 2017 23:02:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 22027 <at> debbugs.gnu.org (full text, mbox):
tags 22027 fixed
close 22027 26.1
quit
Tino Calancha <f92capac <at> gmail.com> writes:
>> We might add a test as well:
> but my previous test is wrong: it works before we apply any patch :-)
> The following looks right:
Thanks, pushed to master [1: 695d50fa0a], [2: 882f81fdb4].
[1: 695d50fa0a]: 2017-06-05 18:57:50 -0400
* test/lisp/subr-tests.el (subr-tests-bug22027): Add test.
http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=695d50fa0a11c6bd98f9f4a9b5a2905d33282316
[2: 882f81fdb4]: 2017-06-05 18:57:32 -0400
* lisp/subr.el (read-passwd): Don't delete return value (Bug#22027).
http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=882f81fdb4ffba773af775d6d6f8920f23163e72
Added tag(s) fixed.
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Mon, 05 Jun 2017 23:02:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 26.1, send any further explanations to
22027 <at> debbugs.gnu.org and Tino Calancha <f92capac <at> gmail.com>
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Mon, 05 Jun 2017 23:02:03 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 04 Jul 2017 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 144 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.