Skip to content

Commit

Permalink
Fix memory corruption bug in StdIO_ReadNextLine
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverkurth committed Feb 7, 2018
1 parent 4f729b6 commit 6ccc073
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions open-vm-tools/lib/misc/vmstdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,6 @@ StdIO_ReadNextLine(FILE *stream, // IN:
data = DynBuf_Get(&b);
size = DynBuf_GetSize(&b);

if (maxBufLength != 0 && size > maxBufLength) {
errno = E2BIG;
goto error;
}

max = DynBuf_GetAllocatedSize(&b);
nr = max - size;

Expand All @@ -232,6 +227,11 @@ StdIO_ReadNextLine(FILE *stream, // IN:
size += nr;
DynBuf_SetSize(&b, size);

if (maxBufLength != 0 && size > maxBufLength) {
errno = E2BIG;
goto error;
}

if (size < max) {
/* SuperFgets() found end-of-line */

Expand Down

0 comments on commit 6ccc073

Please sign in to comment.