public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix pread/pread64
@ 2005-03-03 16:46 Jakub Jelinek
  2005-03-03 17:11 ` Ulrich Drepper
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2005-03-03 16:46 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix pread/pread64
  2005-03-03 16:46 [PATCH] Fix pread/pread64 Jakub Jelinek
@ 2005-03-03 17:11 ` Ulrich Drepper
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2005-03-03 17:11 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers

[-- Attachment #1: Type: text/plain, Size: 315 bytes --]

Jakub Jelinek wrote:

> 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.

Probably best.

--
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-03-03 17:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-03 16:46 [PATCH] Fix pread/pread64 Jakub Jelinek
2005-03-03 17:11 ` Ulrich Drepper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).