Bitcode: Error out instead of crashing on corrupt metadata
authorJustin Bogner <mail@justinbogner.com>
Thu, 17 Mar 2016 20:12:06 +0000 (20:12 +0000)
committerJustin Bogner <mail@justinbogner.com>
Thu, 17 Mar 2016 20:12:06 +0000 (20:12 +0000)
commitae341c6e9b996cbbe8631ce5f0e26168487f71bf
tree0c3991e9afac859fc8ba788214f6f165040e51c9
parent498c56c240ba8e0a0de97e7137ec8c791e79a64d
Bitcode: Error out instead of crashing on corrupt metadata

I hit a crash in the bitcode reader on some corrupt input where an
MDString had somehow been attached to an instruction instead of an
MDNode. This input is pretty bogus, but we shouldn't be crashing on bad
input here.

This change adds error handling in all of the places where we
currently have unchecked casts from Metadata to MDNode, which means
we'll error out instead of crashing for that sort of input.

Unfortunately, I don't have tests. Hitting this requires flipping bits
in the input bitcode, and committing corrupt binary files to catch
these cases is a bit too opaque and unmaintainable.

llvm-svn: 263742
llvm/lib/Bitcode/Reader/BitcodeReader.cpp