[Libguestfs] [PATCH 03/11] daemon: tsk: properly use GUESTFS_MAX_CHUNK_SIZE

Pino Toscano
Fri, 03 Mar 2017 14:32:57 -0000

Pass to fread the size of the buffer allocated, so it can be filled
completely. This is even faster than reading only 4/8 bytes each
iteration.
---
 daemon/sleuthkit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/daemon/sleuthkit.c b/daemon/sleuthkit.c
index e642731..bdbdb0f 100644
--- a/daemon/sleuthkit.c
+++ b/daemon/sleuthkit.c
@@ -122,7 +122,7 @@ send_command_output (const char *cmd)
   /* Send reply message before the file content. */
   reply (NULL, NULL);

-  while ((ret = fread (buffer, 1, sizeof buffer, fp)) > 0) {
+  while ((ret = fread (buffer, 1, GUESTFS_MAX_CHUNK_SIZE, fp)) > 0) {
     ret = send_file_write (buffer, ret);
     if (ret < 0) {
       pclose (fp);
--
2.9.3