mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-05-28 00:21:57 +02:00
patch 9.2.0211: possible crash when setting 'winhighlight'
Problem: possible crash when setting 'winhighlight' Solution: Validate the option value more carefully (Foxe Chen) closes: #19774 Signed-off-by: Foxe Chen <chen.foxe@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
ce4fbda992
commit
88cded7ac0
@@ -5630,6 +5630,7 @@ parse_winhighlight(char_u *opt, int *len, char **errmsg)
|
||||
hl_override_T *arr;
|
||||
int i = 0;
|
||||
int num = 1;
|
||||
int n_colons = 0;
|
||||
|
||||
if (*p == NUL)
|
||||
return NULL;
|
||||
@@ -5640,6 +5641,19 @@ parse_winhighlight(char_u *opt, int *len, char **errmsg)
|
||||
p++;
|
||||
num++;
|
||||
}
|
||||
p = opt;
|
||||
// Check if number of ':' matches number of ','
|
||||
while ((p = vim_strchr(p, ':')) != NULL)
|
||||
{
|
||||
p++;
|
||||
n_colons++;
|
||||
}
|
||||
|
||||
if (num != n_colons)
|
||||
{
|
||||
*errmsg = e_invalid_argument;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
arr = ALLOC_MULT(hl_override_T, num);
|
||||
if (arr == NULL)
|
||||
@@ -5667,6 +5681,8 @@ parse_winhighlight(char_u *opt, int *len, char **errmsg)
|
||||
goto fail;
|
||||
|
||||
fromlen = p - fromname; // Get hl for "from"
|
||||
if (fromlen == 0)
|
||||
goto fail;
|
||||
p++; // Skip colon ':'
|
||||
if (*p == NUL)
|
||||
goto fail;
|
||||
@@ -5683,6 +5699,8 @@ parse_winhighlight(char_u *opt, int *len, char **errmsg)
|
||||
tolen = tmp - toname;
|
||||
p = ++tmp;
|
||||
}
|
||||
if (tolen == 0)
|
||||
goto fail;
|
||||
|
||||
for (int k = 0; k < 2; k++)
|
||||
{
|
||||
|
||||
@@ -362,7 +362,8 @@ let test_values = {
|
||||
\ 'winaltkeys': [['no', 'yes', 'menu'], ['', 'xxx']],
|
||||
\ 'winhighlight': [['Search:Errormsg,Comment:String', 'Search:Comment', ''],
|
||||
\ ['xxx', ',', 'Search:Comment,', 'Search:Errormsg,Comment:String,',
|
||||
\ ':', 'Search:,', 'Search:']],
|
||||
\ ':', 'Search:,', 'Search:', ',Search', ',Search:Test', 'S:,A:B',
|
||||
\ ',', ',S:']],
|
||||
\
|
||||
"\ skipped options
|
||||
\ 'luadll': [[], []],
|
||||
|
||||
@@ -734,6 +734,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
211,
|
||||
/**/
|
||||
210,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user