Skip to content

Commit 0c8485f

Browse files
committed
patch 8.0.0378: possible overflow when reading corrupted undo file
Problem: Another possible overflow when reading corrupted undo file. Solution: Check if allocated size is not too big. (King)
1 parent 3eb1637 commit 0c8485f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/undo.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ unserialize_uep(bufinfo_T *bi, int *error, char_u *file_name)
13851385
{
13861386
int i;
13871387
u_entry_T *uep;
1388-
char_u **array;
1388+
char_u **array = NULL;
13891389
char_u *line;
13901390
int line_len;
13911391

@@ -1402,16 +1402,15 @@ unserialize_uep(bufinfo_T *bi, int *error, char_u *file_name)
14021402
uep->ue_size = undo_read_4c(bi);
14031403
if (uep->ue_size > 0)
14041404
{
1405-
array = (char_u **)U_ALLOC_LINE(sizeof(char_u *) * uep->ue_size);
1405+
if (uep->ue_size < LONG_MAX / (int)sizeof(char_u *))
1406+
array = (char_u **)U_ALLOC_LINE(sizeof(char_u *) * uep->ue_size);
14061407
if (array == NULL)
14071408
{
14081409
*error = TRUE;
14091410
return uep;
14101411
}
14111412
vim_memset(array, 0, sizeof(char_u *) * uep->ue_size);
14121413
}
1413-
else
1414-
array = NULL;
14151414
uep->ue_array = array;
14161415

14171416
for (i = 0; i < uep->ue_size; ++i)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
378,
767769
/**/
768770
377,
769771
/**/

0 commit comments

Comments
 (0)