GNU bug report logs - #53333
Fix for crash in ebrowse

Previous Next

Package: emacs;

Reported by: Jan Stranik <jan <at> stranik.org>

Date: Tue, 18 Jan 2022 00:56:02 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.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 53333 in the body.
You can then email your comments to 53333 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#53333; Package emacs. (Tue, 18 Jan 2022 00:56:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jan Stranik <jan <at> stranik.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 18 Jan 2022 00:56:02 GMT) Full text and rfc822 format available.

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

From: Jan Stranik <jan <at> stranik.org>
To: bug-gnu-emacs <at> gnu.org
Subject: Fix for crash in ebrowse
Date: Mon, 17 Jan 2022 17:35:36 -0500
[Message part 1 (text/plain, inline)]
Hello --

attached is a patch to ebrowse. Noticed a one-off write error in case of
identifiers that are too long and need escaping. The patch prevents the
write to memory outside of allocated range which on my platform caused
segfault.

Best,


[ebrowse-emacs-27.2-fix.diff (text/x-diff, attachment)]
[Message part 3 (text/plain, inline)]
-- 

Jan Stranik

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53333; Package emacs. (Tue, 18 Jan 2022 18:10:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jan Stranik <jan <at> stranik.org>
Cc: 53333 <at> debbugs.gnu.org
Subject: Re: bug#53333: Fix for crash in ebrowse
Date: Tue, 18 Jan 2022 20:09:18 +0200
> Date: Mon, 17 Jan 2022 17:35:36 -0500
> From:  Jan Stranik via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> attached is a patch to ebrowse. Noticed a one-off write error in case of
> identifiers that are too long and need escaping. The patch prevents the
> write to memory outside of allocated range which on my platform caused
> segfault.

Thanks, but can you explain the need for this part:

> !           else {
> !               s++;
> !               break;
> !           }
> !       }

Why do we need to advance the pointer 's' in the 'else' clause? why
not leave it alone?

Or maybe I will understand the reason if you show some simple code
that hits this problem (which would be a good thing of its own, as
we'd then have a test to add to our test suite)?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53333; Package emacs. (Wed, 19 Jan 2022 01:34:02 GMT) Full text and rfc822 format available.

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

From: Jan Stranik <jan <at> stranik.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 53333 <at> debbugs.gnu.org
Subject: Re: bug#53333: Fix for crash in ebrowse
Date: Tue, 18 Jan 2022 20:32:55 -0500
>
> Thanks, but can you explain the need for this part:
>
>> !           else {
>> !               s++;
>> !               break;
>> !           }
>> !       }
>
> Why do we need to advance the pointer 's' in the 'else' clause? why
> not leave it alone?

The identifier is copied from end to the buffer. As we are copying, we
want to escape quote and backslash characters. Normally if we encounter
any of these characters we just prepend \ to in front. If there is not
enough space in the buffer to insert the \, we should increase the s, to
back-out the character that we wanted to escape.

If we would not do that, the first character might not be escaped. If
that character were a quote, it would break the lisp expressions written
later to the BROWSE file.

> Or maybe I will understand the reason if you show some simple code
> that hits this problem (which would be a good thing of its own, as
> we'd then have a test to add to our test suite)?

I encountered this in a c++ header file with very long identifiers that
just filled the buffer but the first character had to be escaped.

-- 

Jan Stranik




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Thu, 20 Jan 2022 11:47:01 GMT) Full text and rfc822 format available.

Notification sent to Jan Stranik <jan <at> stranik.org>:
bug acknowledged by developer. (Thu, 20 Jan 2022 11:47:02 GMT) Full text and rfc822 format available.

Message #16 received at 53333-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jan Stranik <jan <at> stranik.org>
Cc: 53333-done <at> debbugs.gnu.org
Subject: Re: bug#53333: Fix for crash in ebrowse
Date: Thu, 20 Jan 2022 13:45:31 +0200
> From: Jan Stranik <jan <at> stranik.org>
> Cc: 53333 <at> debbugs.gnu.org
> Date: Tue, 18 Jan 2022 20:32:55 -0500
> 
> >
> > Thanks, but can you explain the need for this part:
> >
> >> !           else {
> >> !               s++;
> >> !               break;
> >> !           }
> >> !       }
> >
> > Why do we need to advance the pointer 's' in the 'else' clause? why
> > not leave it alone?
> 
> The identifier is copied from end to the buffer. As we are copying, we
> want to escape quote and backslash characters. Normally if we encounter
> any of these characters we just prepend \ to in front. If there is not
> enough space in the buffer to insert the \, we should increase the s, to
> back-out the character that we wanted to escape.
> 
> If we would not do that, the first character might not be escaped. If
> that character were a quote, it would break the lisp expressions written
> later to the BROWSE file.

Thanks, I installed the change on the emacs-28 branch, and I'm marking
this bug done.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53333; Package emacs. (Thu, 27 Jan 2022 21:21:02 GMT) Full text and rfc822 format available.

Message #19 received at 53333-done <at> debbugs.gnu.org (full text, mbox):

From: Jan Stranik <jan <at> stranik.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 53333-done <at> debbugs.gnu.org
Subject: Re: bug#53333: Fix for crash in ebrowse
Date: Thu, 27 Jan 2022 16:20:37 -0500
>
> Thanks, I installed the change on the emacs-28 branch, and I'm marking
> this bug done.

Thank you for pushing the change.

--

Jan Stranik




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 25 Feb 2022 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 116 days ago.

Previous Next


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