This is an archive of the discontinued LLVM Phabricator instance.

[FileCheck] - Fix possible buffer out of bounds access when parsing --check-prefix.
ClosedPublic

Authored by grimar on Jan 15 2018, 3:05 AM.

Details

Summary

FileCheck tool crashes when trying to parse check prefix if there is no any lines after it.

For example following test would crash if there is no symbols (no EOL mark) after boom:

# REQUIRES: x86
# RUN: <skipped few lines>
# RUN: llvm-readobj -t %t | FileCheck %s --check-prefix=boom

Patch fixes the issue.

Diff Detail

Event Timeline

grimar created this revision.Jan 15 2018, 3:05 AM
grimar updated this revision to Diff 129825.Jan 15 2018, 3:09 AM
  • Added patch context.
arsenm added inline comments.Jan 15 2018, 8:27 AM
test/FileCheck/check-empty2.txt
2–4

Isn't this a non-empty file from the comments?

grimar updated this revision to Diff 129867.Jan 15 2018, 8:44 AM
  • Updated comment.
test/FileCheck/check-empty2.txt
2–4

Clarified the comment.

grimar retitled this revision from [FileCheck] - Do not crash on empty document when parsing --check-prefix. to [FileCheck] - Fix possible out of buffer access when parsing --check-prefix..Jan 15 2018, 8:48 AM
grimar edited the summary of this revision. (Show Details)
grimar retitled this revision from [FileCheck] - Fix possible out of buffer access when parsing --check-prefix. to [FileCheck] - Fix possible buffer out of bounds access when parsing --check-prefix..
arsenm accepted this revision.Jan 15 2018, 8:52 AM

LGTM

This revision is now accepted and ready to land.Jan 15 2018, 8:52 AM
This revision was automatically updated to reflect the committed changes.