diff --git a/open-vm-tools/lib/misc/vmstdio.c b/open-vm-tools/lib/misc/vmstdio.c index 8b90e1e7b..8c447130d 100644 --- a/open-vm-tools/lib/misc/vmstdio.c +++ b/open-vm-tools/lib/misc/vmstdio.c @@ -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; @@ -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 */