$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.
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
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);
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);
}