readv update for POSIX.1-2001
Andreas Schwab
schwab@suse.de
Sun Feb 3 10:41:00 GMT 2002
Thorsten Kukuk <kukuk@suse.de> writes:
|> On Thu, Jan 31, Ulrich Drepper wrote:
|>
|> > Andreas Schwab <schwab@suse.de> writes:
|> >
|> > > POSIX.1-2001 requires that readv fails with EINVAL if the total buffer
|> > > length overflows the range of ssize_t.
|> >
|> > Thanks. I've also made the code a bit more robust.
|>
|> The same is necessary for writev, too. I append a patch for it.
|>
|> Thorsten
Here is an additional patch to make them 64bit clean.
2002-02-03 Andreas Schwab <schwab@suse.de>
* sysdeps/posix/readv.c: Use ssize_t for bytes_read.
* sysdeps/posix/writev.c: Use ssize_t for bytes_written. Fix
comment.
Index: sysdeps/posix/readv.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/posix/readv.c,v
retrieving revision 1.9
diff -u -a -u -r1.9 sysdeps/posix/readv.c
--- sysdeps/posix/readv.c 2002/01/31 19:24:14 1.9
+++ sysdeps/posix/readv.c 2002/02/03 18:36:25
@@ -38,7 +38,7 @@
char *buffer;
char *buffer_start;
size_t bytes;
- int bytes_read;
+ ssize_t bytes_read;
int i;
bool use_malloc = false;
--- sysdeps/posix/writev.c
+++ sysdeps/posix/writev.c
@@ -38,7 +38,7 @@
char *buffer;
register char *bp;
size_t bytes, to_copy;
- int bytes_written;
+ ssize_t bytes_written;
int i;
bool use_malloc = false;
@@ -65,7 +65,7 @@
{
buffer = (char *) malloc (bytes);
if (buffer == NULL)
- /* XXX I don't know whether it is acceptable to try reading
+ /* XXX I don't know whether it is acceptable to try writing
the data in chunks. Probably not so we just fail here. */
return -1;
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
More information about the Libc-hacker
mailing list