[lld] r294280 - COFF: ensure that we handle bad arguments

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 6 20:28:05 PST 2017


Author: compnerd
Date: Mon Feb  6 22:28:05 2017
New Revision: 294280

URL: http://llvm.org/viewvc/llvm-project?rev=294280&view=rev
Log:
COFF: ensure that we handle bad arguments

The parameter to /debugtype is user provided and may be invalid.  Ensure
that we gracefully handle bad input.

Added:
    lld/trunk/test/COFF/invalid-debug-type.test
Modified:
    lld/trunk/COFF/Driver.cpp

Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=294280&r1=294279&r2=294280&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Mon Feb  6 22:28:05 2017
@@ -406,7 +406,8 @@ static unsigned parseDebugType(StringRef
     DebugTypes |= StringSwitch<unsigned>(Type.lower())
                       .Case("cv", static_cast<unsigned>(DebugType::CV))
                       .Case("pdata", static_cast<unsigned>(DebugType::PData))
-                      .Case("fixup", static_cast<unsigned>(DebugType::Fixup));
+                      .Case("fixup", static_cast<unsigned>(DebugType::Fixup))
+                      .Default(0);
   return DebugTypes;
 }
 

Added: lld/trunk/test/COFF/invalid-debug-type.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/invalid-debug-type.test?rev=294280&view=auto
==============================================================================
--- lld/trunk/test/COFF/invalid-debug-type.test (added)
+++ lld/trunk/test/COFF/invalid-debug-type.test Mon Feb  6 22:28:05 2017
@@ -0,0 +1,5 @@
+# RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj
+# RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj
+# RUN: lld-link /debug /debugtype:invalid /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \
+# RUN:   /debugpdb %t1.obj %t2.obj
+




More information about the llvm-commits mailing list