From 3df060d6d0e953bacee8e7899d18b404b5a7262f Mon Sep 17 00:00:00 2001 From: Daichi Hirono Date: Fri, 12 May 2017 16:24:48 +0900 Subject: [PATCH] Change the CHECK failure into function failure. Previously we have CHECK in WriteInternal function to observe short writing. However it turns out short write can happen according to the bug report. To prevent app from crashing due to CHECK failure, the CL removes the CHECK and let WriteInternal return a failure value. Bug: 37561460 Test: libappfuse_tests, manually re-wrote the return value of write() and checked logcat. Change-Id: I6a1e233c3ddb8eb68f59e7c606ad0459b5ca2c6e --- libappfuse/FuseBuffer.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libappfuse/FuseBuffer.cc b/libappfuse/FuseBuffer.cc index b42a04954..fc738db6c 100644 --- a/libappfuse/FuseBuffer.cc +++ b/libappfuse/FuseBuffer.cc @@ -119,7 +119,12 @@ ResultOrAgain WriteInternal(const FuseMessage* self, int fd, int sockflag, co return ResultOrAgain::kFailure; } } - CHECK(static_cast(result) == header.len); + + if (static_cast(result) != header.len) { + LOG(ERROR) << "Written bytes " << result << " is different from length in header " + << header.len; + return ResultOrAgain::kFailure; + } return ResultOrAgain::kSuccess; } }