unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jan Stranik via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 53333@debbugs.gnu.org
Subject: bug#53333: Fix for crash in ebrowse
Date: Mon, 17 Jan 2022 17:35:36 -0500	[thread overview]
Message-ID: <87fspm0z47.fsf@stranik.org> (raw)

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

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,



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ebrowse-emacs-27.2-fix.diff --]
[-- Type: text/x-diff, Size: 974 bytes --]

Dont crash on C source code (one off error)

The fix avoids one off error in case the last character in the buffer
needs to be escaped but there is not enough space in buffer to perform
the escape.

The change just simiply ignores the character in such case.

Author: Jan Stranik <jan@stranik.org>


*** /var/home/janstranik/src/emacs-27.2/lib-src/ebrowse.c~	2021-01-28 11:52:16.000000000 -0600
--- /var/home/janstranik/src/emacs-27.2/lib-src/ebrowse.c	2021-09-24 09:31:49.136287028 -0500
***************
*** 1924,1931 ****
      {
        *--s = *--t;
  
!       if (*s == '"' || *s == '\\')
!         *--s = '\\';
      }
  
    *(matching_regexp_end_buf - 1) = '\0';
--- 1924,1937 ----
      {
        *--s = *--t;
  
!       if (*s == '"' || *s == '\\') {
!           if (s > matching_regexp_buffer)
!               *--s = '\\';
!           else {
!               s++;
!               break;
!           }
!       }
      }
  
    *(matching_regexp_end_buf - 1) = '\0';

[-- Attachment #3: Type: text/plain, Size: 18 bytes --]


-- 

Jan Stranik

             reply	other threads:[~2022-01-17 22:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17 22:35 Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-01-18 18:09 ` bug#53333: Fix for crash in ebrowse Eli Zaretskii
2022-01-19  1:32   ` Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-20 11:45     ` Eli Zaretskii
2022-01-27 21:20       ` Jan Stranik via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fspm0z47.fsf@stranik.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=53333@debbugs.gnu.org \
    --cc=jan@stranik.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).