]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0075: [security]: Buffer underflow with emacs tag file v9.2.0075
authorChristian Brabandt <cb@256bit.org>
Mon, 23 Feb 2026 19:35:25 +0000 (19:35 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 27 Feb 2026 20:46:33 +0000 (20:46 +0000)
Problem:  When parsing a malformed Emacs-style tags file, a 1-byte
          heap-buffer-underflow read occurs if the 0x7f delimiter
          appears at the very beginning of a line. This happens
          because the code attempts to scan backward for a tag
          name from the delimiter without checking if space exists.
          (ehdgks0627, un3xploitable)
Solution: Add a check to ensure the delimiter (p_7f) is not at the
          start of the buffer (lbuf) before attempting to isolate
          the tag name.

GitHub Advisory:
https://github.com/vim/vim/security/advisories/GHSA-xcc8-r6c5-hvwv

Signed-off-by: Christian Brabandt <cb@256bit.org>
src/tag.c
src/testdir/test_taglist.vim
src/version.c

index 4e0cb9a6cda6a876b9105bc0f721644e5a77c4ca..be64ea5ff2cdd8fa7c2ca2a5dc59a7ef6fbcf272 100644 (file)
--- a/src/tag.c
+++ b/src/tag.c
@@ -2022,6 +2022,9 @@ etag_fail:
     }
     else                           // second format: isolate tagname
     {
+       if (p_7f == lbuf)
+           goto etag_fail;
+
        // find end of tagname
        for (p = p_7f - 1; !vim_iswordc(*p); --p)
            if (p == lbuf)
index 506e64f7aee00eac86bbb12f2f9c3b0b742b99b5..42ecc4b76e723322ed91fa2e024f526cd99afa70 100644 (file)
@@ -316,4 +316,20 @@ func Test_evil_emacs_tagfile()
   set tags&
 endfunc
 
+" This used to crash Vim due to a heap-buffer-underflow
+func Test_emacs_tagfile_underflow()
+  CheckFeature emacs_tags
+  " The sequence from the crash artifact:
+  let lines = [
+    \ "\x0c\xff\xffT\x19\x8a",
+    \ "\x19\x19\x0dtags\x19\x19\x19\x00\xff\xff\xff",
+    \ "\x7f3\x0c"
+    \ ]
+  call writefile(lines, 'Xtags', 'D')
+  set tags=Xtags
+  call assert_fails(':tag a', 'E431:')
+
+  set tags&
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index c44e31e5fa14c3e2ad2aa5b4d5714f34134ad029..f2809216a54d8f57f6f861e2f4cb9e1efb60a683 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    75,
 /**/
     74,
 /**/