CVE-2023-48236: Integer Overflow or Wraparound (CWE-190)
value: Vim is an open source command line text editor. When using the z= command, the user may overflow the count with values larger
than MAX_INT. Impact is low, user interaction is required and a crash may not even happen in all situations. This vulnerability has been addressed in commit `73b2d379` which has been included in release version 9.0.2111. Users are advised to upgrade. There are no known workarounds for this vulnerability.
CWE description: The product performs a calculation that can
         produce an integer overflow or wraparound when the logic
         assumes that the resulting value will always be larger than
         the original value. This occurs when an integer value is
         incremented to a value that is too large to store in the
         associated representation. When this occurs, the value may
         become a very small or negative number.
CVSS v3 base score: 4.3
Published: 2023-11-16T23:15Z
Repository: https://github.com/vim/vim
Language: C
Files changed: src/misc1.c, src/testdir/test_spell.vim, src/version.c
Commit date: 2023-11-16 22:04:38 +0100
Commit message: patch 9.0.2111: [security]: overflow in get_number

Problem:  [security]: overflow in get_number
Solution: Return 0 when the count gets too large

[security]: overflow in get_number

When using the z= command, we may overflow the count with values larger
than MAX_INT. So verify that we do not overflow and in case when an
overflow is detected, simply return 0

Signed-off-by: Christian Brabandt <cb@256bit.org>

Diff: diff --git a/src/misc1.c b/src/misc1.c
index 5b008c614a9b..5f9828ebe954 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -973,10 +973,12 @@ get_number(
     {
 	windgoto(msg_row, msg_col);
 	c = safe_vgetc();
 	if (VIM_ISDIGIT(c))
 	{
+	    if (n > INT_MAX / 10)
+		return 0;
 	    n = n * 10 + c - '0';
 	    msg_putchar(c);
 	    ++typed;
 	}
 	else if (c == K_DEL || c == K_KDEL || c == K_BS || c == Ctrl_H)
diff --git a/src/testdir/test_spell.vim b/src/testdir/test_spell.vim
index be0bc55810f0..1ddcd83d5117 100644
--- a/src/testdir/test_spell.vim
+++ b/src/testdir/test_spell.vim
@@ -1075,10 +1075,19 @@ func Test_spell_compatible()
 
   " clean up
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_z_equal_with_large_count()
+  split
+  set spell
+  call setline(1, "ff")
+  norm 0z=337203685477580
+  set nospell
+  bwipe!
+endfunc
+
 let g:test_data_aff1 = [
       \"SET ISO8859-1",
       \"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
       \"",
       \"FOL  \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
diff --git a/src/version.c b/src/version.c
index 86fa528c8af2..66aff800bd38 100644
--- a/src/version.c
+++ b/src/version.c
@@ -702,10 +702,12 @@ static char *(features[]) =
 	NULL
 };
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2111,
 /**/
     2110,
 /**/
     2109,
 /**/

Fixed code: 	    if (n > INT_MAX / 10)
		return 0;
func Test_z_equal_with_large_count()
  split
  set spell
  call setline(1, "ff")
  norm 0z=337203685477580
  set nospell
  bwipe!
endfunc

/**/
    2111,