> util: fix ReadBinaryFile() returning partial contents
>
> If an error occurs and `fread()` returns `0` (nothing was read) then the
> code before this patch would have returned "success" with a partially
> read contents of the file.
https://github.com/bitcoin/bitcoin/pull/20685/commits/8b6e4b3b23027da263d257b342f5d9a53e4032d5
> util: fix WriteBinaryFile() claiming success even if error occurred
>
> `fclose()` is flushing any buffered data to disk, so if it fails then
> that could mean that the data was not completely written to disk.
>
> Thus, check if `fclose()` succeeds and only then claim success from
> `WriteBinaryFile()`.
https://github.com/bitcoin/bitcoin/pull/20685/commits/545bc5f81d60fa6ff7c5cc43a2e9eef82f911466
This is a backport of core#20685 [2&3/20]
Depends on D11012