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
This commit is contained in:
Daichi Hirono 2017-05-12 16:24:48 +09:00
parent a0aaf24d62
commit 3df060d6d0

View file

@ -119,7 +119,12 @@ ResultOrAgain WriteInternal(const FuseMessage<T>* self, int fd, int sockflag, co
return ResultOrAgain::kFailure;
}
}
CHECK(static_cast<uint32_t>(result) == header.len);
if (static_cast<unsigned int>(result) != header.len) {
LOG(ERROR) << "Written bytes " << result << " is different from length in header "
<< header.len;
return ResultOrAgain::kFailure;
}
return ResultOrAgain::kSuccess;
}
}