Skip to content

Commit

Permalink
patch 9.0.2110: [security]: overflow in ex address parsing
Browse files Browse the repository at this point in the history
Problem:  [security]: overflow in ex address parsing
Solution: Verify that lnum is positive, before substracting from
          LONG_MAX

[security]: overflow in ex address parsing

When parsing relative ex addresses one may unintentionally cause an
overflow (because LONG_MAX - lnum will overflow for negative addresses).

So verify that lnum is actually positive before doing the overflow
check.

Signed-off-by: Christian Brabandt <cb@256bit.org>
  • Loading branch information
chrisbra committed Nov 16, 2023
1 parent 58f9bef commit 060623e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ex_docmd.c
Expand Up @@ -4644,7 +4644,7 @@ get_address(
lnum -= n;
else
{
if (n >= LONG_MAX - lnum)
if (lnum >= 0 && n >= LONG_MAX - lnum)
{
emsg(_(e_line_number_out_of_range));
goto error;
Expand Down
4 changes: 4 additions & 0 deletions src/testdir/test_excmd.vim
Expand Up @@ -724,5 +724,9 @@ func Test_write_after_rename()
bwipe!
endfunc

" catch address lines overflow
func Test_ex_address_range_overflow()
call assert_fails(':--+foobar', 'E492:')
endfunc

" vim: shiftwidth=2 sts=2 expandtab
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -704,6 +704,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2110,
/**/
2109,
/**/
Expand Down

0 comments on commit 060623e

Please sign in to comment.