* bug#47718: Fix epa-file-insert-file-contents substring error
@ 2021-04-12 4:20 juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-04-12 8:14 ` Lars Ingebrigtsen
0 siblings, 1 reply; 9+ messages in thread
From: juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-04-12 4:20 UTC (permalink / raw
To: 47718
[-- Attachment #1: Type: text/plain, Size: 235 bytes --]
Hi
I think substring occurs error when TO is longer than its content.
This patch will fix the substring bug in epa-file-insert-file-contents.
The last commit this line was 2008, so no one seems not using it, though ;)
Thanks,
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-args-out-of-range-error-in-epa-file-insert-file-.patch --]
[-- Type: text/x-patch; name=0001-Fix-args-out-of-range-error-in-epa-file-insert-file-.patch, Size: 1165 bytes --]
From da85a87962cad14fb6dee231fe019fadafa1107e Mon Sep 17 00:00:00 2001
From: Junya Takahashi <jutakat@gmail.com>
Date: Mon, 12 Apr 2021 13:09:35 +0900
Subject: [PATCH] Fix args-out-of-range error in epa-file-insert-file-contents
Fix error below:
$ echo -n test > test
$ gpg -c test
elisp> (epa-file-insert-file-contents "test.gpg" nil 0 5)
;; => Args out of range: "test", 0, 5
---
lisp/epa-file.el | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lisp/epa-file.el b/lisp/epa-file.el
index e46e3684c8..33bf5adabe 100644
--- a/lisp/epa-file.el
+++ b/lisp/epa-file.el
@@ -198,7 +198,9 @@ epa-file-insert-file-contents
(mapcar #'car (epg-context-result-for
context 'encrypted-to)))
(if (or beg end)
- (setq string (substring string (or beg 0) end)))
+ (setq string (substring string
+ (or beg 0)
+ (and end (min end (length string))))))
(save-excursion
;; If visiting, bind off buffer-file-name so that
;; file-locking will not ask whether we should
--
2.31.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* bug#47718: Fix epa-file-insert-file-contents substring error
2021-04-12 4:20 bug#47718: Fix epa-file-insert-file-contents substring error juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-04-12 8:14 ` Lars Ingebrigtsen
2021-04-12 11:57 ` Eli Zaretskii
2021-04-12 12:51 ` juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 2 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2021-04-12 8:14 UTC (permalink / raw
To: juntaka; +Cc: 47718
juntaka <juntaka@protonmail.com> writes:
> I think substring occurs error when TO is longer than its content.
> This patch will fix the substring bug in epa-file-insert-file-contents.
Thanks; applied to Emacs 28.
This change was small enough to apply without assigning copyright to the
FSF, but for future patches you want to submit, it might make sense to
get the paperwork started now, so that subsequent patches can be applied
speedily. Would you be willing to sign such paperwork?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#47718: Fix epa-file-insert-file-contents substring error
2021-04-12 8:14 ` Lars Ingebrigtsen
@ 2021-04-12 11:57 ` Eli Zaretskii
2021-04-12 12:57 ` juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-04-13 7:01 ` Lars Ingebrigtsen
2021-04-12 12:51 ` juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors
1 sibling, 2 replies; 9+ messages in thread
From: Eli Zaretskii @ 2021-04-12 11:57 UTC (permalink / raw
To: Lars Ingebrigtsen; +Cc: juntaka, 47718
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Mon, 12 Apr 2021 10:14:34 +0200
> Cc: 47718@debbugs.gnu.org
>
> juntaka <juntaka@protonmail.com> writes:
>
> > I think substring occurs error when TO is longer than its content.
> > This patch will fix the substring bug in epa-file-insert-file-contents.
>
> Thanks; applied to Emacs 28.
Actually, I wonder whether this is TRT: why should we silently accept
invalid inputs when substring itself doesn't?
IOW, can we please have a real-life use case where this happens, and
where silently "fixing" this input is TRT? TIA.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#47718: Fix epa-file-insert-file-contents substring error
2021-04-12 8:14 ` Lars Ingebrigtsen
2021-04-12 11:57 ` Eli Zaretskii
@ 2021-04-12 12:51 ` juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-04-13 7:02 ` Lars Ingebrigtsen
1 sibling, 1 reply; 9+ messages in thread
From: juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-04-12 12:51 UTC (permalink / raw
To: Lars Ingebrigtsen; +Cc: 47718@debbugs.gnu.org
Hi Lars,
Thank you for merging.
Yes, I will do to sign the paperwork.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Monday, April 12, 2021 5:14 PM, Lars Ingebrigtsen <larsi@gnus.org> wrote:
> juntaka juntaka@protonmail.com writes:
>
> > I think substring occurs error when TO is longer than its content.
> > This patch will fix the substring bug in epa-file-insert-file-contents.
>
> Thanks; applied to Emacs 28.
>
> This change was small enough to apply without assigning copyright to the
> FSF, but for future patches you want to submit, it might make sense to
> get the paperwork started now, so that subsequent patches can be applied
> speedily. Would you be willing to sign such paperwork?
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> (domestic pets only, the antidote for overdose, milk.)
> bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#47718: Fix epa-file-insert-file-contents substring error
2021-04-12 11:57 ` Eli Zaretskii
@ 2021-04-12 12:57 ` juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-04-12 13:23 ` Eli Zaretskii
2021-04-13 7:01 ` Lars Ingebrigtsen
1 sibling, 1 reply; 9+ messages in thread
From: juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-04-12 12:57 UTC (permalink / raw
To: Eli Zaretskii; +Cc: Lars Ingebrigtsen, 47718@debbugs.gnu.org
Hi Eli,
In my use case, I'm writing an elisp to show the first line of each file on dired.
It does not need to visit and read entire file. So I just try to limit by (window-width).
But if Emacs try to decrypt GPG files, then I got such error.
Regards,
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Monday, April 12, 2021 8:57 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> > From: Lars Ingebrigtsen larsi@gnus.org
> > Date: Mon, 12 Apr 2021 10:14:34 +0200
> > Cc: 47718@debbugs.gnu.org
> > juntaka juntaka@protonmail.com writes:
> >
> > > I think substring occurs error when TO is longer than its content.
> > > This patch will fix the substring bug in epa-file-insert-file-contents.
> >
> > Thanks; applied to Emacs 28.
>
> Actually, I wonder whether this is TRT: why should we silently accept
> invalid inputs when substring itself doesn't?
>
> IOW, can we please have a real-life use case where this happens, and
> where silently "fixing" this input is TRT? TIA.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#47718: Fix epa-file-insert-file-contents substring error
2021-04-12 12:57 ` juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-04-12 13:23 ` Eli Zaretskii
2021-04-13 0:27 ` juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2021-04-12 13:23 UTC (permalink / raw
To: juntaka; +Cc: larsi, 47718
> Date: Mon, 12 Apr 2021 12:57:28 +0000
> From: juntaka <juntaka@protonmail.com>
> Cc: Lars Ingebrigtsen <larsi@gnus.org>, "47718@debbugs.gnu.org" <47718@debbugs.gnu.org>
>
> In my use case, I'm writing an elisp to show the first line of each file on dired.
> It does not need to visit and read entire file. So I just try to limit by (window-width).
> But if Emacs try to decrypt GPG files, then I got such error.
Doesn't that mean the problem is in your application code?
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#47718: Fix epa-file-insert-file-contents substring error
2021-04-12 13:23 ` Eli Zaretskii
@ 2021-04-13 0:27 ` juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 0 replies; 9+ messages in thread
From: juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-04-13 0:27 UTC (permalink / raw
To: Eli Zaretskii; +Cc: larsi@gnus.org, 47718@debbugs.gnu.org
> Doesn't that mean the problem is in your application code?
I think insert-file-contents should behave same regardless gpg file or not.
$ echo -n test > file
$ gpg -c file
elisp> (insert-file-contents "file" nil 0 4) ;; no error
elisp> (insert-file-contents "file" nil 0 5) ;; no error
elisp> (insert-file-contents "file.gpg" nil 0 4) ;; no error
elisp> (insert-file-contents "file.gpg" nil 0 5) ;; error
I had no chance to fix that on my side.
Best,
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Monday, April 12, 2021 10:23 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> > Date: Mon, 12 Apr 2021 12:57:28 +0000
> > From: juntaka juntaka@protonmail.com
> > Cc: Lars Ingebrigtsen larsi@gnus.org, "47718@debbugs.gnu.org" 47718@debbugs.gnu.org
> > In my use case, I'm writing an elisp to show the first line of each file on dired.
> > It does not need to visit and read entire file. So I just try to limit by (window-width).
> > But if Emacs try to decrypt GPG files, then I got such error.
>
> Doesn't that mean the problem is in your application code?
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#47718: Fix epa-file-insert-file-contents substring error
2021-04-12 11:57 ` Eli Zaretskii
2021-04-12 12:57 ` juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-04-13 7:01 ` Lars Ingebrigtsen
1 sibling, 0 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2021-04-13 7:01 UTC (permalink / raw
To: Eli Zaretskii; +Cc: juntaka, 47718
Eli Zaretskii <eliz@gnu.org> writes:
> Actually, I wonder whether this is TRT: why should we silently accept
> invalid inputs when substring itself doesn't?
insert-file-contents does not signal an error in this case, so
epa-file-insert-file-contents shouldn't either.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#47718: Fix epa-file-insert-file-contents substring error
2021-04-12 12:51 ` juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-04-13 7:02 ` Lars Ingebrigtsen
0 siblings, 0 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2021-04-13 7:02 UTC (permalink / raw
To: juntaka; +Cc: 47718@debbugs.gnu.org
juntaka <juntaka@protonmail.com> writes:
> Yes, I will do to sign the paperwork.
Great; here's the form to get started:
Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.
Please use your full legal name (in ASCII characters) as the subject
line of the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES
[What is the name of the program or package you're contributing to?]
Emacs
[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]
[Do you have an employer who might have a basis to claim to own
your changes? Do you attend a school which might make such a claim?]
[For the copyright registration, what country are you a citizen of?]
[What year were you born?]
[Please write your email address here.]
[Please write your postal address here.]
[Which files have you changed so far, and which new files have you written
so far?]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-04-13 7:02 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-12 4:20 bug#47718: Fix epa-file-insert-file-contents substring error juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-04-12 8:14 ` Lars Ingebrigtsen
2021-04-12 11:57 ` Eli Zaretskii
2021-04-12 12:57 ` juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-04-12 13:23 ` Eli Zaretskii
2021-04-13 0:27 ` juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-04-13 7:01 ` Lars Ingebrigtsen
2021-04-12 12:51 ` juntaka via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-04-13 7:02 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.