Fix metadata format error checking (#16036)
authorJan Kotas <jkotas@microsoft.com>
Mon, 29 Jan 2018 13:21:44 +0000 (05:21 -0800)
committerGitHub <noreply@github.com>
Mon, 29 Jan 2018 13:21:44 +0000 (05:21 -0800)
NextStream_Verify can return NULL for invalid file. Report error for it instead of AVing.
Similar check is around the other calls to NextStream_Verify. It was missing here for some reason.

src/md/runtime/mdinternaldisp.cpp

index e6e25a2..6498b35 100644 (file)
@@ -74,6 +74,11 @@ CheckFileFormat(
         }
         // Get next stream.
         PSTORAGESTREAM pNext = pStream->NextStream_Verify();
+        if (pNext == NULL)
+        {   // Stream header is corrupted.
+            Debug_ReportError("Invalid stream header - cannot get next stream header.");
+            IfFailGo(CLDB_E_FILE_CORRUPT);
+        }
         
         // Check that stream header is within the buffer.
         if (((LPBYTE)pStream >= ((LPBYTE)pData + cbData)) ||