Skip to contentSkip to conversation

vim: Fix CVE-2023-2609 and CVE-2023-2610

PATCH New Ashish Sharma 1 participant 1 message Jul 10, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vim: Fix CVE-2023-2609 and CVE-2023-2610

import patches from ubuntu to fix
CVE-2023-2609
CVE-2023-2610

Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/vim/tree/debian/patches?h=applied/ubuntu/devel&id=586a63887e677551384eea2ab03eb22bd1117338
Upstream commit
https://git.launchpad.net/ubuntu/+source/vim/tree/debian/patches/CVE-2023-2609.patch?h=applied/ubuntu/devel&id=586a63887e677551384eea2ab03eb22bd1117338
&
https://git.launchpad.net/ubuntu/+source/vim/tree/debian/patches/CVE-2023-2610.patch?h=applied/ubuntu/devel&id=586a63887e677551384eea2ab03eb22bd1117338]

---
 .../vim/files/CVE-2023-2609.patch             |  59 ++++++++++
 .../vim/files/CVE-2023-2610.patch             | 106 ++++++++++++++++++
 meta/recipes-support/vim/vim.inc              |   2 +
 3 files changed, 167 insertions(+)
 create mode 100644 meta/recipes-support/vim/files/CVE-2023-2609.patch
 create mode 100644 meta/recipes-support/vim/files/CVE-2023-2610.patch
meta/recipes-support/vim/files/CVE-2023-2609.patch new file +59 -0
new file mode 100644
index 0000000000..c60d5efa25
@@ -0,0 +1,59 @@
+From d1ae8366aff286d41e7f5bc513cc0a1af5130aad Mon Sep 17 00:00:00 2001
+From: Bram Moolenaar <[email protected]>
+Date: Tue, 9 May 2023 17:09:30 +0100
+Subject: [PATCH] patch 9.0.1531: crash when register contents ends up being
+ invalid
+
+Problem:    Crash when register contents ends up being invalid.
+Solution:   Check "y_array" is not NULL.
+
++Upstream-Status: Backport [import from ubuntu https://git.launchpad.net/ubuntu/+source/vim/tree/debian/patches?h=applied/ubuntu/devel&id=586a63887e677551384eea2ab03eb22bd1117338
++Upstream commit https://git.launchpad.net/ubuntu/+source/vim/tree/debian/patches/CVE-2023-2609.patch?h=applied/ubuntu/devel&id=586a63887e677551384eea2ab03eb22bd1117338]
++CVE: CVE-2023-2609
++Signed-off-by:  Ashish Sharma <[email protected]>
+---
+ src/register.c                 |  2 +-
+ src/testdir/test_registers.vim | 17 +++++++++++++++++
+ 2 files changed, 20 insertions(+), 1 deletion(-)
+
+diff --git a/src/register.c b/src/register.c
+index f3df79cfd642..e481d843c249 100644
+--- a/src/register.c
++++ b/src/register.c
+@@ -301,7 +301,7 @@ get_register(
+     if (copy)
+     {
+ 	// If we run out of memory some or all of the lines are empty.
+-	if (reg->y_size == 0)
++	if (reg->y_size == 0 || y_current->y_array == NULL)
+ 	    reg->y_array = NULL;
+ 	else
+ 	    reg->y_array = ALLOC_MULT(char_u *, reg->y_size);
+diff --git a/src/testdir/test_registers.vim b/src/testdir/test_registers.vim
+index e966932478d8..33ea0f4bd3e6 100644
+--- a/src/testdir/test_registers.vim
++++ b/src/testdir/test_registers.vim
+@@ -835,6 +835,23 @@ func Test_end_reg_executing()
+   bwipe!
+ endfunc
+ 
++" This was causing a crash because y_append was ending up being NULL
++func Test_zero_y_append()
++  " Run in a separate Vim instance because changing 'encoding' may cause
++  " trouble for later tests.
++  let lines =<< trim END
++      d
++      silent ?n
++      next <sfile>
++      so
++      sil! norm 0V€PSP
++      set enc=latin1
++       
++  END
++  call writefile(lines, 'XTest_zero_y_append', 'D')
++  call RunVim([], [], '-u NONE -i NONE -e -s -S XTest_zero_y_append -c qa\!')
++endfunc
++
+ " Make sure that y_append is correctly reset
+ " and the previous register is working as expected
+ func Test_register_y_append_reset()
meta/recipes-support/vim/files/CVE-2023-2610.patch new file +106 -0

106 lines not on this page · raw message

meta/recipes-support/vim/vim.inc +2 -0
index 309c91848d..59f3183f3e 100644
@@ -18,6 +18,8 @@ SRC_URI = "git://github.com/vim/vim.git;branch=master;protocol=https \
            file://vim-add-knob-whether-elf.h-are-checked.patch \
            file://0001-src-Makefile-improve-reproducibility.patch \
            file://no-path-adjust.patch \
+	   file://CVE-2023-2609..patch \
+	   file://CVE-2023-2610..patch \
            "
 
 PV .= ".1527"
Signature · 1 line
2.17.1