This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix pread/pread64


Hi!

Swapping nbytes with offset certainly is quite bad.

BTW, you have changed read and other posix/bits/unistd.h functions
to add __builtin_constant_p checks and simply __chk_fail whenever the user
lies about buffer size, thanks for that.
But I wonder whether the same shouldn't be done for socket/bits/socket2.h
and libio/bits/stdio3.h (the newly added) functions as well.
If you agree, I'll cook up a patch.

2005-03-03  Jakub Jelinek  <jakub@redhat.com>

	* posix/bits/unistd.h (pread, pread64): Don't swap function arguments.

--- libc/posix/bits/unistd.h.jj	2005-03-03 07:50:14.000000000 +0100
+++ libc/posix/bits/unistd.h	2005-03-03 16:48:51.801860029 +0100
@@ -39,13 +39,13 @@ extern ssize_t __pread64_chk (int __fd, 
   (__bos0 (buf) != (size_t) -1						      \
    && (!__builtin_constant_p (nbytes) || (nbytes) > __bos0 (buf))	      \
    ? __pread64_chk (fd, buf, nbytes, offset, __bos0 (buf))		      \
-   : pread (fd, buf, offset, nbytes))
+   : pread (fd, buf, nbytes, offset))
 # else
 #  define pread(fd, buf, nbytes, offset) \
   (__bos0 (buf) != (size_t) -1						      \
    && (!__builtin_constant_p (nbytes) || (nbytes) > __bos0 (buf))	      \
    ? __pread_chk (fd, buf, nbytes, offset, __bos0 (buf))		      \
-   : pread (fd, buf, offset, nbytes))
+   : pread (fd, buf, nbytes, offset))
 # endif
 
 # ifdef __USE_LARGEFILE64
@@ -53,7 +53,7 @@ extern ssize_t __pread64_chk (int __fd, 
   (__bos0 (buf) != (size_t) -1						      \
    && (!__builtin_constant_p (nbytes) || (nbytes) > __bos0 (buf))	      \
    ? __pread64_chk (fd, buf, nbytes, offset, __bos0 (buf))		      \
-   : pread64 (fd, buf, offset, nbytes))
+   : pread64 (fd, buf, nbytes, offset))
 # endif
 #endif
 

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]