GNU bug report logs - #47718
Fix epa-file-insert-file-contents substring error

Previous Next

Package: emacs;

Reported by: juntaka <juntaka <at> protonmail.com>

Date: Mon, 12 Apr 2021 06:02:02 UTC

Severity: normal

Tags: fixed

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

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 47718 in the body.
You can then email your comments to 47718 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#47718; Package emacs. (Mon, 12 Apr 2021 06:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to juntaka <juntaka <at> protonmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 12 Apr 2021 06:02:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: juntaka <juntaka <at> protonmail.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: Fix epa-file-insert-file-contents substring error
Date: Mon, 12 Apr 2021 04:20:13 +0000
[Message part 1 (text/plain, inline)]
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,
[0001-Fix-args-out-of-range-error-in-epa-file-insert-file-.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47718; Package emacs. (Mon, 12 Apr 2021 08:15:01 GMT) Full text and rfc822 format available.

Message #8 received at 47718 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: juntaka <juntaka <at> protonmail.com>
Cc: 47718 <at> debbugs.gnu.org
Subject: Re: bug#47718: Fix epa-file-insert-file-contents substring error
Date: Mon, 12 Apr 2021 10:14:34 +0200
juntaka <juntaka <at> 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




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 12 Apr 2021 08:15:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 47718 <at> debbugs.gnu.org and juntaka <juntaka <at> protonmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 12 Apr 2021 08:15:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47718; Package emacs. (Mon, 12 Apr 2021 11:59:01 GMT) Full text and rfc822 format available.

Message #15 received at 47718 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: juntaka <at> protonmail.com, 47718 <at> debbugs.gnu.org
Subject: Re: bug#47718: Fix epa-file-insert-file-contents substring error
Date: Mon, 12 Apr 2021 14:57:51 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Mon, 12 Apr 2021 10:14:34 +0200
> Cc: 47718 <at> debbugs.gnu.org
> 
> juntaka <juntaka <at> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47718; Package emacs. (Mon, 12 Apr 2021 13:24:01 GMT) Full text and rfc822 format available.

Message #18 received at 47718 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: juntaka <juntaka <at> protonmail.com>
Cc: larsi <at> gnus.org, 47718 <at> debbugs.gnu.org
Subject: Re: bug#47718: Fix epa-file-insert-file-contents substring error
Date: Mon, 12 Apr 2021 16:23:10 +0300
> Date: Mon, 12 Apr 2021 12:57:28 +0000
> From: juntaka <juntaka <at> protonmail.com>
> Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, "47718 <at> debbugs.gnu.org" <47718 <at> 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?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47718; Package emacs. (Mon, 12 Apr 2021 14:17:02 GMT) Full text and rfc822 format available.

Message #21 received at 47718 <at> debbugs.gnu.org (full text, mbox):

From: juntaka <juntaka <at> protonmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: "47718 <at> debbugs.gnu.org" <47718 <at> debbugs.gnu.org>
Subject: Re: bug#47718: Fix epa-file-insert-file-contents substring error
Date: Mon, 12 Apr 2021 12:51:40 +0000
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 <at> gnus.org> wrote:

> juntaka juntaka <at> 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






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47718; Package emacs. (Mon, 12 Apr 2021 14:17:03 GMT) Full text and rfc822 format available.

Message #24 received at 47718 <at> debbugs.gnu.org (full text, mbox):

From: juntaka <juntaka <at> protonmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>,
 "47718 <at> debbugs.gnu.org" <47718 <at> debbugs.gnu.org>
Subject: Re: bug#47718: Fix epa-file-insert-file-contents substring error
Date: Mon, 12 Apr 2021 12:57:28 +0000
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 <at> gnu.org> wrote:

> > From: Lars Ingebrigtsen larsi <at> gnus.org
> > Date: Mon, 12 Apr 2021 10:14:34 +0200
> > Cc: 47718 <at> debbugs.gnu.org
> > juntaka juntaka <at> 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.






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47718; Package emacs. (Tue, 13 Apr 2021 00:28:01 GMT) Full text and rfc822 format available.

Message #27 received at 47718 <at> debbugs.gnu.org (full text, mbox):

From: juntaka <juntaka <at> protonmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: "larsi <at> gnus.org" <larsi <at> gnus.org>,
 "47718 <at> debbugs.gnu.org" <47718 <at> debbugs.gnu.org>
Subject: Re: bug#47718: Fix epa-file-insert-file-contents substring error
Date: Tue, 13 Apr 2021 00:27:04 +0000
> 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 <at> gnu.org> wrote:

> > Date: Mon, 12 Apr 2021 12:57:28 +0000
> > From: juntaka juntaka <at> protonmail.com
> > Cc: Lars Ingebrigtsen larsi <at> gnus.org, "47718 <at> debbugs.gnu.org" 47718 <at> 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?






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47718; Package emacs. (Tue, 13 Apr 2021 07:02:02 GMT) Full text and rfc822 format available.

Message #30 received at 47718 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: juntaka <at> protonmail.com, 47718 <at> debbugs.gnu.org
Subject: Re: bug#47718: Fix epa-file-insert-file-contents substring error
Date: Tue, 13 Apr 2021 09:01:30 +0200
Eli Zaretskii <eliz <at> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#47718; Package emacs. (Tue, 13 Apr 2021 07:03:02 GMT) Full text and rfc822 format available.

Message #33 received at 47718 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: juntaka <juntaka <at> protonmail.com>
Cc: "47718 <at> debbugs.gnu.org" <47718 <at> debbugs.gnu.org>
Subject: Re: bug#47718: Fix epa-file-insert-file-contents substring error
Date: Tue, 13 Apr 2021 09:02:03 +0200
juntaka <juntaka <at> 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 <at> 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?]




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 11 May 2021 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 351 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.