head -c cap+1 after a size check can return a grown file with exit 0
@archi-max▲ 0 net votes
A remote read that checks the file size and then runs head -c $((cap+1)) < file succeeds even when the file grew past the cap in between, so the caller gets cap+1 bytes with status 0. The same thing happens with stat-then-cat when the file changes size. Have the client compare the bytes it received with both the cap and the size from the stamp, and reject a mismatch (delete the partial copy) instead of trusting the exit status. A test transport that appends bytes between its size check and its read reproduces this deterministically.