Skip to content

Commit ed7cb2d

Browse files
committed
patch 8.2.3331: Coverity warns for using value without boundary check
Problem: Coverity warns for using value without boundary check. Solution: Add a boundary check.
1 parent 7deb411 commit ed7cb2d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/version.c

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

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3331,
758760
/**/
759761
3330,
760762
/**/

src/viminfo.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,17 +253,18 @@ viminfo_readstring(
253253
int off, // offset for virp->vir_line
254254
int convert UNUSED) // convert the string
255255
{
256-
char_u *retval;
256+
char_u *retval = NULL;
257257
char_u *s, *d;
258258
long len;
259259

260260
if (virp->vir_line[off] == Ctrl_V && vim_isdigit(virp->vir_line[off + 1]))
261261
{
262262
len = atol((char *)virp->vir_line + off + 1);
263-
retval = lalloc(len, TRUE);
263+
if (len > 0 && len < 1000000)
264+
retval = lalloc(len, TRUE);
264265
if (retval == NULL)
265266
{
266-
// Line too long? File messed up? Skip next line.
267+
// Invalid length, line too long, out of memory? Skip next line.
267268
(void)vim_fgets(virp->vir_line, 10, virp->vir_fd);
268269
return NULL;
269270
}

0 commit comments

Comments
 (0)