]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1172: [security]: overflow with 'nostartofline' and Ex command in tag file v9.1.1172
authorzeertzjq <zeertzjq@outlook.com>
Wed, 5 Mar 2025 19:05:18 +0000 (20:05 +0100)
committerChristian Brabandt <cb@256bit.org>
Wed, 5 Mar 2025 19:05:18 +0000 (20:05 +0100)
Problem:  heap-buffer-overflow with 'nostartofline' and Ex command in
          tag file.
Solution: Set cursor column when moving cursor to line 1 (zeertzjq).

closes: #16796

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

index 21ff5636ac65c12123037fd80acb4aea79235872..f61f116744f0f6dc0277684fe17189fb7e14636c 100644 (file)
--- a/src/tag.c
+++ b/src/tag.c
@@ -3997,6 +3997,8 @@ jumpto_tag(
            ++sandbox;
 #endif
            curwin->w_cursor.lnum = 1;          // start command in line 1
+           curwin->w_cursor.col = 0;
+           curwin->w_cursor.coladd = 0;
            do_cmdline_cmd(pbuf);
            retval = OK;
 
index 67bd95fe1176a45322b810b5c3ab26856813c301..e4b258c57a605ed1696380bd5101aa44ee3cbdbe 100644 (file)
@@ -1633,4 +1633,21 @@ func Test_tag_guess_short()
   set tags& cpoptions-=t
 endfunc
 
+func Test_tag_excmd_with_nostartofline()
+  call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
+        \ "f\tXfile\tascii"],
+        \ 'Xtags', 'D')
+  call writefile(['f', 'foobar'], 'Xfile', 'D')
+
+  set nostartofline
+  new Xfile
+  setlocal tags=Xtags
+  normal! G$
+  " This used to cause heap-buffer-overflow
+  tag f
+
+  bwipe!
+  set startofline&
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index aac7ed1aeb3b963258840420512cc17a7128bc76..cfb661e7067737b3a0996f31b588abe5bc358919 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1172,
 /**/
     1171,
 /**/