This is an archive of the discontinued LLVM Phabricator instance.

Verify sizes when trying to read a BitcodeAbbrevOp
ClosedPublic

Authored by filcab on Apr 15 2015, 10:10 AM.

Details

Summary

Make sure we don't try to read more than we can when reading abbrev
operands.

Bug found with AFL fuzz.

Diff Detail

Repository
rL LLVM

Event Timeline

filcab updated this revision to Diff 23782.Apr 15 2015, 10:10 AM
filcab retitled this revision from to Verify sizes when trying to read a BitcodeAbbrevOp.
filcab updated this object.
filcab edited the test plan for this revision. (Show Details)
filcab added a reviewer: rafael.
filcab added a subscriber: Unknown Object (MLST).
rafael added inline comments.Apr 21 2015, 10:23 AM
include/llvm/Bitcode/BitstreamReader.h
215 ↗(On Diff #23782)

getMaxChunkSize.

Or just make this a constant. It doesn't need to be a function, right?

test/Bitcode/invalid.test
59 ↗(On Diff #23782)

If you have a testcase handy for the 4 cases, please add them.

True. I'll change it to be a constant.

Submitted before I wanted.
I'll also figure it out and add tests for each case.

filcab updated this revision to Diff 24280.Apr 23 2015, 3:23 AM

Changed MaxChunkSize to be a constant.
Made the check earlier, when abbrevs are read, and added asserts to
read/skipAbbreviatedField.
Replaced the test with two tests, one for Fixed field, and one for a VBR
field.

rafael accepted this revision.Apr 23 2015, 4:54 AM
rafael edited edge metadata.

LGTM

This revision is now accepted and ready to land.Apr 23 2015, 4:54 AM
This revision was automatically updated to reflect the committed changes.