From 3745d58587a984105f2d6024f5adebc44bf2330b Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Mon, 3 Jan 2022 15:00:35 +0100 Subject: [PATCH] filewrapper: `_Exit` instead of `CHECK` failing Raw `SAPI_RAW_PCHECK` may dump core, depending on environment settings (issue #89). This is undesirable in the face of invalid command-line arguments. Signed-off-by: Christian Blichmann --- sandboxed_api/tools/filewrapper/filewrapper.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sandboxed_api/tools/filewrapper/filewrapper.cc b/sandboxed_api/tools/filewrapper/filewrapper.cc index ed8fcf0..863c1ad 100644 --- a/sandboxed_api/tools/filewrapper/filewrapper.cc +++ b/sandboxed_api/tools/filewrapper/filewrapper.cc @@ -97,7 +97,12 @@ class File { } ~File() { fclose(stream_); } - void Check() { SAPI_RAW_PCHECK(!ferror(stream_), "I/O on %s", name_); } + void Check() { + if (ferror(stream_)) { + SAPI_RAW_PLOG(ERROR, "I/O on %s", name_); + _Exit(EXIT_FAILURE); + } + } FILE* get() const { return stream_; }