fix
authorChristian Grothoff <christian@grothoff.org>
Fri, 7 May 2010 09:19:18 +0000 (09:19 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 7 May 2010 09:19:18 +0000 (09:19 +0000)
src/fs/fs.c

index a569ce27a57b7878d97b19e2309aef4377f500eb..d2ac711f2ba949c41bb69d1fd797e9ddbffb57dd 100644 (file)
@@ -1097,14 +1097,16 @@ copy_from_reader (struct GNUNET_BIO_WriteHandle *wh,
   char buf[32 * 1024];
   uint64_t off;
   size_t ret;
+  size_t left;
   char *emsg;
 
   emsg = NULL;
   off = 0;
   while (off < fi->data.file.file_size)
     {
+      left = GNUNET_MIN (sizeof(buf), fi->data.file.file_size - off);
       ret = fi->data.file.reader (fi->data.file.reader_cls,
-                                 off, sizeof (buf),
+                                 off, left,
                                  buf,
                                  &emsg);
       if (ret == 0)