HomePhabricator

[libFuzzer] don't use /dev/null for DiscardOuput in Fuchsia.

Authored by charco on Oct 29 2019, 3:38 PM.

Description

[libFuzzer] don't use /dev/null for DiscardOuput in Fuchsia.

Summary:

This commit moves the DiscardOutput function in FuzzerIO to
FuzzerUtil, so fuchsia can have its own specialized version.

In fuchsia, accessing /dev/null is not supported, and there's nothing
similar to a file that discards everything that is written to it. The
way of doing something similar in fuchsia is by using fdio_null_create
and binding that to a file descriptor with fdio_bind_to_fd.

This change should fix one of the issues with the -close_fd_mask flag
in libfuzzer, in which closing stdout was not working due to
fopen("/dev/null", "w") returning NULL.

Reviewers: kcc, aarongreen

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D69593