Skip to content

Commit

Permalink
patch 8.2.3595: check for signed overflow might not work everywhere
Browse files Browse the repository at this point in the history
Problem:    Check for signed overflow might not work everywhere.
Solution:   Limit to 32 bit int. (closes #9043, closes #9067)
  • Loading branch information
brammool committed Nov 14, 2021
1 parent 786e05b commit 0d5a12e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/getchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1001,20 +1001,24 @@ ins_typebuf(
}
else
{
int extra;

/*
* Need to allocate a new buffer.
* In typebuf.tb_buf there must always be room for 3 * (MAXMAPLEN + 4)
* characters. We add some extra room to avoid having to allocate too
* often.
*/
newoff = MAXMAPLEN + 4;
newlen = typebuf.tb_len + addlen + newoff + 4 * (MAXMAPLEN + 4);
if (newlen < 0) // string is getting too long
extra = addlen + newoff + 4 * (MAXMAPLEN + 4);
if (typebuf.tb_len > 2147483647 - extra)
{
// string is getting too long for a 32 bit int
emsg(_(e_toocompl)); // also calls flush_buffers
setcursor();
return FAIL;
}
newlen = typebuf.tb_len + extra;
s1 = alloc(newlen);
if (s1 == NULL) // out of memory
return FAIL;
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,8 @@ static char *(features[]) =

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

0 comments on commit 0d5a12e

Please sign in to comment.