about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-03-06 20:56:52 +0000
committerUlrich Drepper <drepper@redhat.com>2005-03-06 20:56:52 +0000
commit4625abbf26ae8ca7bd49a00de0c744136323699b (patch)
treee6c46b25deec24333dc0fd7ec01c22d7eb0d5397
parentfcb050599109dac133dd444e4e3712a82987fe3c (diff)
downloadglibc-4625abbf26ae8ca7bd49a00de0c744136323699b.tar.gz
glibc-4625abbf26ae8ca7bd49a00de0c744136323699b.tar.xz
glibc-4625abbf26ae8ca7bd49a00de0c744136323699b.zip
(recv): Avoid calls to the _chk variant if we know the call succeeds. (recvfrom): Likewise.
-rw-r--r--socket/bits/socket2.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/socket/bits/socket2.h b/socket/bits/socket2.h
index 0ccb24ca31..e752879e6e 100644
--- a/socket/bits/socket2.h
+++ b/socket/bits/socket2.h
@@ -25,6 +25,7 @@ extern ssize_t __recv_chk (int __fd, void *__buf, size_t __n, size_t __buflen,
 			   int __flags);
 #define recv(fd, buf, n, flags) \
   (__bos0 (buf) != (size_t) -1						      \
+   && (!__builtin_constant_p (n) || (n) > __bos0 (buf))			      \
    ? __recv_chk (fd, buf, n, __bos0 (buf), flags)			      \
    : recv (fd, buf, n, flags))
 
@@ -34,5 +35,6 @@ extern ssize_t __recvfrom_chk (int __fd, void *__restrict __buf, size_t __n,
 			       socklen_t *__restrict __addr_len);
 #define recvfrom(fd, buf, n, flags, addr, addr_len) \
   (__bos0 (buf) != (size_t) -1						      \
+   && (!__builtin_constant_p (n) || (n) > __bos0 (buf))			      \
    ? __recvfrom_chk (fd, buf, n, __bos0 (buf), flags, addr, addr_len)	      \
    : recvfrom (fd, buf, n, flags, addr, addr_len))