aboutsummaryrefslogtreecommitdiff
path: root/socket
diff options
context:
space:
mode:
Diffstat (limited to 'socket')
-rw-r--r--socket/bits/socket2.h34
1 files changed, 13 insertions, 21 deletions
diff --git a/socket/bits/socket2.h b/socket/bits/socket2.h
index 9c8ac69..b28cde5 100644
--- a/socket/bits/socket2.h
+++ b/socket/bits/socket2.h
@@ -33,17 +33,12 @@ extern ssize_t __REDIRECT (__recv_chk_warn,
__fortify_function ssize_t
recv (int __fd, void *__buf, size_t __n, int __flags)
{
- if (__glibc_objsize0 (__buf) != (size_t) -1)
- {
- if (!__builtin_constant_p (__n))
- return __recv_chk (__fd, __buf, __n, __glibc_objsize0 (__buf),
- __flags);
-
- if (__n > __glibc_objsize0 (__buf))
- return __recv_chk_warn (__fd, __buf, __n, __glibc_objsize0 (__buf),
- __flags);
- }
- return __recv_alias (__fd, __buf, __n, __flags);
+ size_t sz = __glibc_objsize0 (__buf);
+ if (__glibc_safe_or_unknown_len (__n, sizeof (char), sz))
+ return __recv_alias (__fd, __buf, __n, __flags);
+ if (__glibc_unsafe_len (__n, sizeof (char), sz))
+ return __recv_chk_warn (__fd, __buf, __n, sz, __flags);
+ return __recv_chk (__fd, __buf, __n, sz, __flags);
}
extern ssize_t __recvfrom_chk (int __fd, void *__restrict __buf, size_t __n,
@@ -66,14 +61,11 @@ __fortify_function ssize_t
recvfrom (int __fd, void *__restrict __buf, size_t __n, int __flags,
__SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len)
{
- if (__glibc_objsize0 (__buf) != (size_t) -1)
- {
- if (!__builtin_constant_p (__n))
- return __recvfrom_chk (__fd, __buf, __n, __glibc_objsize0 (__buf),
- __flags, __addr, __addr_len);
- if (__n > __glibc_objsize0 (__buf))
- return __recvfrom_chk_warn (__fd, __buf, __n, __glibc_objsize0 (__buf),
- __flags, __addr, __addr_len);
- }
- return __recvfrom_alias (__fd, __buf, __n, __flags, __addr, __addr_len);
+ size_t sz = __glibc_objsize0 (__buf);
+ if (__glibc_safe_or_unknown_len (__n, sizeof (char), sz))
+ return __recvfrom_alias (__fd, __buf, __n, __flags, __addr, __addr_len);
+ if (__glibc_unsafe_len (__n, sizeof (char), sz))
+ return __recvfrom_chk_warn (__fd, __buf, __n, sz, __flags, __addr,
+ __addr_len);
+ return __recvfrom_chk (__fd, __buf, __n, sz, __flags, __addr, __addr_len);
}