Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add close_fd_mask functionality to AFL driver. Summary: Add support for env var AFL_DRIVER_CLOSE_FD_MASK which behaves the same as libFuzzer's -close_fd_mask=1. Also add tests. Reviewers: kcc, vitalybuka, morehouse Reviewed By: morehouse Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D60334 llvm-svn: 358703
- Loading branch information
1 parent
d573aa0
commit 139e216
Showing
4 changed files
with
125 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
REQUIRES: linux | ||
RUN: %no_fuzzer_cpp_compiler %S/AFLDriverTest.cpp %libfuzzer_src/afl/afl_driver.cpp -o %t-AFLDriverTest | ||
|
||
; Test that not specifying AFL_DRIVER_CLOSE_FD_MASK works as intended. | ||
RUN: echo -n "abc" > %t.file3 | ||
RUN: unset AFL_DRIVER_CLOSE_FD_MASK | ||
RUN: %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=STDERR,STDOUT | ||
STDOUT: STDOUT MESSAGE | ||
STDERR: STDERR MESSAGE | ||
|
||
; Test that stdout is closed properly. | ||
RUN: AFL_DRIVER_CLOSE_FD_MASK=1 %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=NOT_STDOUT,STDERR | ||
NOT_STDOUT-NOT: STDOUT MESSAGE | ||
|
||
; Test that stderr is closed properly. | ||
RUN: AFL_DRIVER_CLOSE_FD_MASK=2 %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=NOT_STDERR,STDOUT | ||
NOT_STDERR-NOT: STDERR MESSAGE | ||
|
||
; Test that both are closed properly. | ||
RUN: AFL_DRIVER_CLOSE_FD_MASK=3 %run %t-AFLDriverTest < %t.file3 2>&1 | FileCheck %s --check-prefixes=NOT_STDERR,NOT_STDOUT | ||
|
||
; Test that a stack is printed when we close stderr | ||
RUN: echo -n "abcd" > %t.file4 | ||
RUN: AFL_DRIVER_CLOSE_FD_MASK=2 not %run %t-AFLDriverTest < %t.file4 2>&1 | FileCheck %s --check-prefixes=ASAN_CRASH,STDOUT,NOT_STDERR | ||
ASAN_CRASH: ERROR: AddressSanitizer | ||
|
||
; Test that a stack is written to the stderr duplicate file when we close stderr | ||
; and specify a duplicate. | ||
RUN: rm -f %t.stderr | ||
RUN: AFL_DRIVER_STDERR_DUPLICATE_FILENAME=%t.stderr AFL_DRIVER_CLOSE_FD_MASK=2 not %run %t-AFLDriverTest < %t.file4 | ||
RUN: cat %t.stderr | FileCheck %s --check-prefixes=ASAN_CRASH,NOT_STDERR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters