unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: master 3139551: Don’t attempt to modify constant strings
       [not found] ` <20200517052513.C95BC20A2C@vcs0.savannah.gnu.org>
@ 2020-05-17 11:22   ` Dmitry Gutov
  2020-05-17 17:01     ` Paul Eggert
  2020-05-17 11:24   ` Dmitry Gutov
  1 sibling, 1 reply; 11+ messages in thread
From: Dmitry Gutov @ 2020-05-17 11:22 UTC (permalink / raw)
  To: emacs-devel, Paul Eggert

On 17.05.2020 08:25, Paul Eggert wrote:
>   ;; WORKAROUND: This is nominally a constant, but the text properties
>   ;; are not preserved thru dump if use defconst.  See bug#21237.
>   (defvar elisp--xref-format
> -  (let ((str "(%s %s)"))
> -    (put-text-property 1 3 'face 'font-lock-keyword-face str)
> -    (put-text-property 4 6 'face 'font-lock-function-name-face str)
> -    str))
> +  #("(%s %s)"
> +    1 3 (face font-lock-keyword-face)
> +    4 6 (face font-lock-function-name-face)))

Seems like the comment is calling for some further changes.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: master 3139551: Don’t attempt to modify constant strings
       [not found] ` <20200517052513.C95BC20A2C@vcs0.savannah.gnu.org>
  2020-05-17 11:22   ` master 3139551: Don’t attempt to modify constant strings Dmitry Gutov
@ 2020-05-17 11:24   ` Dmitry Gutov
  2020-05-17 17:10     ` Paul Eggert
  1 sibling, 1 reply; 11+ messages in thread
From: Dmitry Gutov @ 2020-05-17 11:24 UTC (permalink / raw)
  To: emacs-devel, Paul Eggert

On 17.05.2020 08:25, Paul Eggert wrote:
>   ;;
> -;; (password-cache-add "test" "foo")
> +;; (password-cache-add "test" (copy-sequence "foo"))
>   ;;  => nil

This seems like a false positive.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: master 3139551: Don’t attempt to modify constant strings
  2020-05-17 11:22   ` master 3139551: Don’t attempt to modify constant strings Dmitry Gutov
@ 2020-05-17 17:01     ` Paul Eggert
  0 siblings, 0 replies; 11+ messages in thread
From: Paul Eggert @ 2020-05-17 17:01 UTC (permalink / raw)
  To: Dmitry Gutov, emacs-devel

On 5/17/20 4:22 AM, Dmitry Gutov wrote:
> On 17.05.2020 08:25, Paul Eggert wrote:
>>   ;; WORKAROUND: This is nominally a constant, but the text properties
>>   ;; are not preserved thru dump if use defconst.  See bug#21237.

> Seems like the comment is calling for some further changes.

Yes, quite true. That's on my todo list, though it may need to wait until we
start insisting on portable rather than traditional dumping.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: master 3139551: Don’t attempt to modify constant strings
  2020-05-17 11:24   ` Dmitry Gutov
@ 2020-05-17 17:10     ` Paul Eggert
  2020-05-17 18:02       ` Dmitry Gutov
  0 siblings, 1 reply; 11+ messages in thread
From: Paul Eggert @ 2020-05-17 17:10 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel

On 5/17/20 4:24 AM, Dmitry Gutov wrote:
>> -;; (password-cache-add "test" "foo")
>> +;; (password-cache-add "test" (copy-sequence "foo"))
>>   ;;  => nil
> 
> This seems like a false positive.

It's just a comment. Since there are so many ways that a password cache can be
cleared and clearing means the strings holding passwords need to be mutable, I
thought it better for the comment to reflect good practice.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: master 3139551: Don’t attempt to modify constant strings
  2020-05-17 17:10     ` Paul Eggert
@ 2020-05-17 18:02       ` Dmitry Gutov
  2020-05-17 21:36         ` Paul Eggert
  0 siblings, 1 reply; 11+ messages in thread
From: Dmitry Gutov @ 2020-05-17 18:02 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel

On 17.05.2020 20:10, Paul Eggert wrote:
> Since there are so many ways that a password cache can be
> cleared and clearing means the strings holding passwords need to be mutable,

Um, why?

A cache normally doesn't mutate the values, it only holds on to them.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: master 3139551: Don’t attempt to modify constant strings
  2020-05-17 18:02       ` Dmitry Gutov
@ 2020-05-17 21:36         ` Paul Eggert
  2020-05-17 21:54           ` Dmitry Gutov
  0 siblings, 1 reply; 11+ messages in thread
From: Paul Eggert @ 2020-05-17 21:36 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel

On 5/17/20 11:02 AM, Dmitry Gutov wrote:
> On 17.05.2020 20:10, Paul Eggert wrote:
>> Since there are so many ways that a password cache can be
>> cleared and clearing means the strings holding passwords need to be mutable,
> 
> Um, why?

It's done under the assumption that it makes Emacs more "secure".

> A cache normally doesn't mutate the values, it only holds on to them.

This cache mutates its values, unfortunately.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: master 3139551: Don’t attempt to modify constant strings
  2020-05-17 21:36         ` Paul Eggert
@ 2020-05-17 21:54           ` Dmitry Gutov
  2020-05-17 23:16             ` Paul Eggert
  0 siblings, 1 reply; 11+ messages in thread
From: Dmitry Gutov @ 2020-05-17 21:54 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel

On 18.05.2020 00:36, Paul Eggert wrote:
>> A cache normally doesn't mutate the values, it only holds on to them.
> This cache mutates its values, unfortunately.

Perhaps it should call (copy-sequence val) itself, then? That would be a 
good development practice.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: master 3139551: Don’t attempt to modify constant strings
  2020-05-17 21:54           ` Dmitry Gutov
@ 2020-05-17 23:16             ` Paul Eggert
  2020-05-17 23:24               ` Dmitry Gutov
  2020-05-18  7:03               ` Andreas Schwab
  0 siblings, 2 replies; 11+ messages in thread
From: Paul Eggert @ 2020-05-17 23:16 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel

On 5/17/20 2:54 PM, Dmitry Gutov wrote:
> On 18.05.2020 00:36, Paul Eggert wrote:
>>> A cache normally doesn't mutate the values, it only holds on to them.
>> This cache mutates its values, unfortunately.
> 
> Perhaps it should call (copy-sequence val) itself, then? That would be a good
> development practice.

That would run afoul of the whole idea of clearing the string in the first
place, which was to avoid having one's password lying around in memory for a bad
actor to grab it.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: master 3139551: Don’t attempt to modify constant strings
  2020-05-17 23:16             ` Paul Eggert
@ 2020-05-17 23:24               ` Dmitry Gutov
  2020-05-18  7:03               ` Andreas Schwab
  1 sibling, 0 replies; 11+ messages in thread
From: Dmitry Gutov @ 2020-05-17 23:24 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel

On 18.05.2020 02:16, Paul Eggert wrote:
> That would run afoul of the whole idea of clearing the string in the first
> place, which was to avoid having one's password lying around in memory for a bad
> actor to grab it.

OK, okay. I see the full design now.

Sorry for the false alarm.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: master 3139551: Don’t attempt to modify constant strings
  2020-05-17 23:16             ` Paul Eggert
  2020-05-17 23:24               ` Dmitry Gutov
@ 2020-05-18  7:03               ` Andreas Schwab
  2020-05-18 22:49                 ` Paul Eggert
  1 sibling, 1 reply; 11+ messages in thread
From: Andreas Schwab @ 2020-05-18  7:03 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel, Dmitry Gutov

On Mai 17 2020, Paul Eggert wrote:

> That would run afoul of the whole idea of clearing the string in the first
> place, which was to avoid having one's password lying around in memory for a bad
> actor to grab it.

But doing it in the caller is equally bad.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: master 3139551: Don’t attempt to modify constant strings
  2020-05-18  7:03               ` Andreas Schwab
@ 2020-05-18 22:49                 ` Paul Eggert
  0 siblings, 0 replies; 11+ messages in thread
From: Paul Eggert @ 2020-05-18 22:49 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: emacs-devel, Dmitry Gutov

[-- Attachment #1: Type: text/plain, Size: 355 bytes --]

On 5/18/20 12:03 AM, Andreas Schwab wrote:
> On Mai 17 2020, Paul Eggert wrote:
> 
>> That would run afoul of the whole idea of clearing the string in the first
>> place, which was to avoid having one's password lying around in memory for a bad
>> actor to grab it.
> 
> But doing it in the caller is equally bad.

True, thanks, I installed the attached.

[-- Attachment #2: 0001-Improve-password-cache-add-example-in-comment.patch --]
[-- Type: text/x-patch, Size: 895 bytes --]

From 4d6e592cf5f48ca8aab9ec6569759f25cd1d1677 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 18 May 2020 15:42:18 -0700
Subject: [PATCH] Improve password-cache-add example in comment

* lisp/password-cache.el: Improve comment.  See Andreas Schwab in:
https://lists.gnu.org/r/emacs-devel/2020-05/msg02422.html
---
 lisp/password-cache.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/password-cache.el b/lisp/password-cache.el
index 86d802f283..f5007579a8 100644
--- a/lisp/password-cache.el
+++ b/lisp/password-cache.el
@@ -31,7 +31,8 @@
 ;; ;; Minibuffer prompt for password.
 ;;  => "foo"
 ;;
-;; (password-cache-add "test" (copy-sequence "foo"))
+;; (password-cache-add "test" (read-passwd "Password? "))
+;; ;; Minibuffer prompt from read-passwd, which returns "foo".
 ;;  => nil
 
 ;; (password-read "Password? " "test")
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-05-18 22:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20200517052512.20679.37725@vcs0.savannah.gnu.org>
     [not found] ` <20200517052513.C95BC20A2C@vcs0.savannah.gnu.org>
2020-05-17 11:22   ` master 3139551: Don’t attempt to modify constant strings Dmitry Gutov
2020-05-17 17:01     ` Paul Eggert
2020-05-17 11:24   ` Dmitry Gutov
2020-05-17 17:10     ` Paul Eggert
2020-05-17 18:02       ` Dmitry Gutov
2020-05-17 21:36         ` Paul Eggert
2020-05-17 21:54           ` Dmitry Gutov
2020-05-17 23:16             ` Paul Eggert
2020-05-17 23:24               ` Dmitry Gutov
2020-05-18  7:03               ` Andreas Schwab
2020-05-18 22:49                 ` Paul Eggert

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).