From a7cc8d67bea4e489060d95b5a550b5358d85c389 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Mon, 1 Feb 2010 19:19:34 +0000 Subject: [PATCH] * partialy revert r8246; we're working in units of one here, so the number of units read actualy _is_ the number of bytes read here. --- citadel/file_ops.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/citadel/file_ops.c b/citadel/file_ops.c index b7b0cb3f3..ced5a31d5 100644 --- a/citadel/file_ops.c +++ b/citadel/file_ops.c @@ -621,6 +621,7 @@ void cmd_read(char *cmdbuf) { long start_pos; size_t bytes; + size_t actual_bytes; char *buf = NULL; start_pos = extract_long(cmdbuf, 0); @@ -636,8 +637,10 @@ void cmd_read(char *cmdbuf) buf = malloc(bytes + 1); fseek(CC->download_fp, start_pos, 0); - if (fread(buf, 1, bytes, CC->download_fp) == 1) { - cprintf("%d %d\n", BINARY_FOLLOWS, (int)bytes); + + actual_bytes = fread(buf, 1, bytes, CC->download_fp); + if (actual_bytes > 0) { + cprintf("%d %d\n", BINARY_FOLLOWS, (int)actual_bytes); client_write(buf, bytes); } else { -- 2.30.2