* file_ops.c: cmd_read() now returns a short read at end-of-file instead of
authorMichael Hampton <io_error@uncensored.citadel.org>
Sun, 29 Sep 2002 04:41:43 +0000 (04:41 +0000)
committerMichael Hampton <io_error@uncensored.citadel.org>
Sun, 29 Sep 2002 04:41:43 +0000 (04:41 +0000)
  4096, this prevents trailing garbage on the downloaded file; also it now
  succeeds if the requested number of bytes is > 4096; it simply returns
  only 4096 bytes.

citadel/ChangeLog
citadel/file_ops.c

index ba660c009c3057af5013d4262bb8618a96000e52..34a94238c315f59a2ca75c629a90eef93562a7c3 100644 (file)
@@ -1,4 +1,10 @@
  $Log$
+ Revision 601.10  2002/09/29 04:41:43  error
+ * file_ops.c: cmd_read() now returns a short read at end-of-file instead of
+   4096, this prevents trailing garbage on the downloaded file; also it now
+   succeeds if the requested number of bytes is > 4096; it simply returns
+   only 4096 bytes.
+
  Revision 601.9  2002/09/27 06:53:20  error
  * Allow multiple simultaneous IPC connections.  All changes necessary for
    the client to use the new code are necessarily included.
@@ -4016,4 +4022,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index ca089bac18224577b25db8132f1f844810f38611..a6ce2f82a931832a7a1929276246d46c56a2c0f2 100644 (file)
@@ -680,7 +680,8 @@ void cmd_ucls(char *cmd)
 void cmd_read(char *cmdbuf)
 {
        long start_pos;
-       int bytes;
+       size_t bytes;
+       size_t actual_bytes;
        char buf[4096];
 
        start_pos = extract_long(cmdbuf, 0);
@@ -692,16 +693,12 @@ void cmd_read(char *cmdbuf)
                return;
        }
 
-       if (bytes > 4096) {
-               cprintf("%d You may not read more than 4096 bytes.\n",
-                       ERROR);
-               return;
-       }
+       if (bytes > 4096) bytes = 4096;
 
        fseek(CC->download_fp, start_pos, 0);
-       fread(buf, bytes, 1, CC->download_fp);
-       cprintf("%d %d\n", BINARY_FOLLOWS, bytes);
-       client_write(buf, bytes);
+       actual_bytes = fread(buf, 1, bytes, CC->download_fp);
+       cprintf("%d %d\n", BINARY_FOLLOWS, actual_bytes);
+       client_write(buf, actual_bytes);
 }