From 615c1d5321b1f3af8312198474ccb97b0b0c7daa Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Sun, 5 Oct 2025 21:20:27 +0100 Subject: [PATCH] Explicitly cast both sides of the comparison to "long long", otherwise there is an overflow on 32-bit systems and stop-at-size stops at the wrong point (#166). --- src/pv/transfer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pv/transfer.c b/src/pv/transfer.c index d6c64d2..1f65ca1 100644 --- a/src/pv/transfer.c +++ b/src/pv/transfer.c @@ -349,7 +349,7 @@ static int pv__transfer_read(pvstate_t state, int fd, bool *eof_in, bool *eof_ou */ if (state->control.stop_at_size && !state->control.linemode) { off_t bytes_remaining_to_read = state->control.size - state->transfer.total_bytes_read; - if (bytes_can_read > (size_t) bytes_remaining_to_read) { + if ((long long) bytes_can_read > (long long) bytes_remaining_to_read) { debug("%lld > (%lld-%lld=%lld): %s", (long long) bytes_can_read, (long long) (state->control.size), (long long) state->transfer.total_bytes_read, (long long) bytes_remaining_to_read, "truncating for stop-at-size");