Skip to content

Commit 3eb1637

Browse files
committed
patch 8.0.0377: possible overflow when reading corrupted undo file
Problem: Possible overflow when reading corrupted undo file. Solution: Check if allocated size is not too big. (King)
1 parent 6d3c858 commit 3eb1637

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/undo.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,7 +1787,7 @@ u_read_undo(char_u *name, char_u *hash, char_u *orig_name)
17871787
linenr_T line_lnum;
17881788
colnr_T line_colnr;
17891789
linenr_T line_count;
1790-
int num_head = 0;
1790+
long num_head = 0;
17911791
long old_header_seq, new_header_seq, cur_header_seq;
17921792
long seq_last, seq_cur;
17931793
long last_save_nr = 0;
@@ -1974,7 +1974,8 @@ u_read_undo(char_u *name, char_u *hash, char_u *orig_name)
19741974
* When there are no headers uhp_table is NULL. */
19751975
if (num_head > 0)
19761976
{
1977-
uhp_table = (u_header_T **)U_ALLOC_LINE(
1977+
if (num_head < LONG_MAX / (long)sizeof(u_header_T *))
1978+
uhp_table = (u_header_T **)U_ALLOC_LINE(
19781979
num_head * sizeof(u_header_T *));
19791980
if (uhp_table == NULL)
19801981
goto error;

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+
377,
767769
/**/
768770
376,
769771
/**/

0 commit comments

Comments
 (0)