mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.1.0985: crash with large number in regexp
Problem: Crash with large number in regexp. (Kuang-che Wu) Solution: Check for long becoming negative int. (closes #)
This commit is contained in:
@@ -2228,7 +2228,7 @@ regatom(int *flagp)
|
|||||||
default: i = -1; break;
|
default: i = -1; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < 0)
|
if (i < 0 || i > INT_MAX)
|
||||||
EMSG2_RET_NULL(
|
EMSG2_RET_NULL(
|
||||||
_("E678: Invalid character after %s%%[dxouU]"),
|
_("E678: Invalid character after %s%%[dxouU]"),
|
||||||
reg_magic == MAGIC_ALL);
|
reg_magic == MAGIC_ALL);
|
||||||
@@ -3293,7 +3293,7 @@ coll_get_char(void)
|
|||||||
case 'u': nr = gethexchrs(4); break;
|
case 'u': nr = gethexchrs(4); break;
|
||||||
case 'U': nr = gethexchrs(8); break;
|
case 'U': nr = gethexchrs(8); break;
|
||||||
}
|
}
|
||||||
if (nr < 0)
|
if (nr < 0 || nr > INT_MAX)
|
||||||
{
|
{
|
||||||
/* If getting the number fails be backwards compatible: the character
|
/* If getting the number fails be backwards compatible: the character
|
||||||
* is a backslash. */
|
* is a backslash. */
|
||||||
|
@@ -1212,13 +1212,36 @@ func Test_search_Ctrl_L_combining()
|
|||||||
call Incsearch_cleanup()
|
call Incsearch_cleanup()
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_large_hex_chars()
|
func Test_large_hex_chars1()
|
||||||
" This used to cause a crash, the character becomes an NFA state.
|
" This used to cause a crash, the character becomes an NFA state.
|
||||||
try
|
try
|
||||||
/\%Ufffffc23
|
/\%Ufffffc23
|
||||||
catch
|
catch
|
||||||
call assert_match('E678:', v:exception)
|
call assert_match('E678:', v:exception)
|
||||||
endtry
|
endtry
|
||||||
|
try
|
||||||
|
set re=1
|
||||||
|
/\%Ufffffc23
|
||||||
|
catch
|
||||||
|
call assert_match('E678:', v:exception)
|
||||||
|
endtry
|
||||||
|
set re&
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_large_hex_chars2()
|
||||||
|
" This used to cause a crash, the character becomes an NFA state.
|
||||||
|
try
|
||||||
|
/[\Ufffffc1f]
|
||||||
|
catch
|
||||||
|
call assert_match('E486:', v:exception)
|
||||||
|
endtry
|
||||||
|
try
|
||||||
|
set re=1
|
||||||
|
/[\Ufffffc1f]
|
||||||
|
catch
|
||||||
|
call assert_match('E486:', v:exception)
|
||||||
|
endtry
|
||||||
|
set re&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_one_error_msg()
|
func Test_one_error_msg()
|
||||||
|
@@ -779,6 +779,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
985,
|
||||||
/**/
|
/**/
|
||||||
984,
|
984,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user