]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix memory corruption bug in StdIO_ReadNextLine
authorOliver Kurth <okurth@vmware.com>
Wed, 7 Feb 2018 00:32:39 +0000 (16:32 -0800)
committerOliver Kurth <okurth@vmware.com>
Wed, 7 Feb 2018 00:32:39 +0000 (16:32 -0800)
open-vm-tools/lib/misc/vmstdio.c

index 8b90e1e7b369d9d9aa4a5d647528589cf4705146..8c447130dc175b6578881d263812e1634f35422e 100644 (file)
@@ -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 */