[PATCH] D64507: [BitcodeReader] Validate OpNum, before accessing Record array.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 11 02:56:46 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL365750: [BitcodeReader] Validate OpNum, before accessing Record array. (authored by fhahn, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D64507?vs=209010&id=209153#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64507/new/

https://reviews.llvm.org/D64507

Files:
  llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/trunk/test/Bitcode/Inputs/invalid-fcmp-opnum.bc
  llvm/trunk/test/Bitcode/invalid.test


Index: llvm/trunk/test/Bitcode/invalid.test
===================================================================
--- llvm/trunk/test/Bitcode/invalid.test
+++ llvm/trunk/test/Bitcode/invalid.test
@@ -235,3 +235,8 @@
 RUN:   FileCheck --check-prefix=NONPOINTER-ATOMICRMW %s
 
 NONPOINTER-ATOMICRMW: Invalid record
+
+RUN: not llvm-dis -disable-output %p/Inputs/invalid-fcmp-opnum.bc 2>&1 | \
+RUN:   FileCheck --check-prefix=INVALID-FCMP-OPNUM %s
+
+INVALID-FCMP-OPNUM: Invalid record: operand number exceeded available operands
Index: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
===================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -4165,6 +4165,10 @@
           popValue(Record, OpNum, NextValueNo, LHS->getType(), RHS))
         return error("Invalid record");
 
+      if (OpNum >= Record.size())
+        return error(
+            "Invalid record: operand number exceeded available operands");
+
       unsigned PredVal = Record[OpNum];
       bool IsFP = LHS->getType()->isFPOrFPVectorTy();
       FastMathFlags FMF;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64507.209153.patch
Type: text/x-patch
Size: 1147 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190711/7bb78ff3/attachment.bin>


More information about the llvm-commits mailing list