This is an archive of the discontinued LLVM Phabricator instance.

Fix input validation issues in llvm-as/llvm-dis
ClosedPublic

Authored by sl on May 7 2015, 4:18 PM.

Details

Summary
  1. llvm-as/llvm-dis tools do not check for input filename length.
  2. llvm-dis does not verify the Streamer variable against nullptr properly, so the M variable could be uninitialized (e.g. if the input file does not exist) leading to null dref.

Diff Detail

Repository
rL LLVM

Event Timeline

sl updated this revision to Diff 25254.May 7 2015, 4:18 PM
sl retitled this revision from to Fix input validation issues in llvm-as/llvm-dis.
sl updated this object.
sl edited the test plan for this revision. (Show Details)
sl set the repository for this revision to rL LLVM.
sl added a subscriber: Unknown Object (MLST).
samsonov added inline comments.
tools/llvm-as/llvm-as.cpp
67 ↗(On Diff #25254)

Can you use StringRef::endswith(".ll") instead?

sl updated this revision to Diff 25330.May 8 2015, 7:49 AM
sl removed rL LLVM as the repository for this revision.

Can you use StringRef::endswith(".ll") instead?

Sure, done. It also may be useful to use llvm::StringRef::endswith_lower().

sl set the repository for this revision to rL LLVM.May 8 2015, 7:50 AM
samsonov accepted this revision.May 8 2015, 9:07 AM
samsonov added a reviewer: samsonov.

LGTM with one comment.

tools/llvm-as/llvm-as.cpp
67 ↗(On Diff #25330)

IFN.drop_back(3).str() (here and below)

This revision is now accepted and ready to land.May 8 2015, 9:07 AM
sl updated this revision to Diff 25340.May 8 2015, 9:23 AM
sl edited edge metadata.
sl added a comment.May 9 2015, 7:12 PM

LGTM with one comment.

Alexey, could you please commit this? Thank you.

This revision was automatically updated to reflect the committed changes.