[PATCH] D35069: [Frontend] Verify that the bitstream is not empty before reading the serialised diagnostics

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 7 03:25:43 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL307384: [Frontend] Verify that the bitstream is not empty before reading (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D35069?vs=105462&id=105612#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35069

Files:
  cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp
  cfe/trunk/test/Index/Inputs/empty.dia
  cfe/trunk/test/Index/read-empty-diags.test


Index: cfe/trunk/test/Index/read-empty-diags.test
===================================================================
--- cfe/trunk/test/Index/read-empty-diags.test
+++ cfe/trunk/test/Index/read-empty-diags.test
@@ -0,0 +1,2 @@
+// RUN: not c-index-test -read-diagnostics %S/Inputs/empty.dia 2>&1 | FileCheck %s
+// CHECK: Trouble deserializing file (Invalid File): Invalid diagnostics signature
Index: cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp
===================================================================
--- cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp
+++ cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp
@@ -27,6 +27,9 @@
   llvm::BitstreamCursor Stream(**Buffer);
   Optional<llvm::BitstreamBlockInfo> BlockInfo;
 
+  if (Stream.AtEndOfStream())
+    return SDError::InvalidSignature;
+
   // Sniff for the signature.
   if (Stream.Read(8) != 'D' ||
       Stream.Read(8) != 'I' ||


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35069.105612.patch
Type: text/x-patch
Size: 920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170707/1e9c1b70/attachment.bin>


More information about the cfe-commits mailing list