aboutsummaryrefslogtreecommitdiff
path: root/posix
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@sourceware.org>2020-12-15 23:50:09 +0530
committerSiddhesh Poyarekar <siddhesh@sourceware.org>2020-12-31 16:55:21 +0530
commitf9de8bfe1a731c309b91d175b4f6f4aeb786effa (patch)
treede1e299076d996829aacc7aecff1ae98c11a87af /posix
parent2a3224c53653214cbba2ec23424702193c80ea3b (diff)
downloadglibc-f9de8bfe1a731c309b91d175b4f6f4aeb786effa.tar
glibc-f9de8bfe1a731c309b91d175b4f6f4aeb786effa.tar.gz
glibc-f9de8bfe1a731c309b91d175b4f6f4aeb786effa.tar.bz2
glibc-f9de8bfe1a731c309b91d175b4f6f4aeb786effa.zip
nonstring: Enable __FORTIFY_LEVEL=3
Use __builtin_dynamic_object_size in the remaining functions that don't have compiler builtins as is the case for string functions.
Diffstat (limited to 'posix')
-rw-r--r--posix/bits/unistd.h120
1 files changed, 66 insertions, 54 deletions
diff --git a/posix/bits/unistd.h b/posix/bits/unistd.h
index 725a83eb0d..6c5ed0c618 100644
--- a/posix/bits/unistd.h
+++ b/posix/bits/unistd.h
@@ -35,13 +35,14 @@ extern ssize_t __REDIRECT (__read_chk_warn,
__fortify_function __wur ssize_t
read (int __fd, void *__buf, size_t __nbytes)
{
- if (__bos0 (__buf) != (size_t) -1)
+ if (__glibc_objsize0 (__buf) != (size_t) -1)
{
if (!__builtin_constant_p (__nbytes))
- return __read_chk (__fd, __buf, __nbytes, __bos0 (__buf));
+ return __read_chk (__fd, __buf, __nbytes, __glibc_objsize0 (__buf));
- if (__nbytes > __bos0 (__buf))
- return __read_chk_warn (__fd, __buf, __nbytes, __bos0 (__buf));
+ if (__nbytes > __glibc_objsize0 (__buf))
+ return __read_chk_warn (__fd, __buf, __nbytes,
+ __glibc_objsize0 (__buf));
}
return __read_alias (__fd, __buf, __nbytes);
}
@@ -77,14 +78,15 @@ extern ssize_t __REDIRECT (__pread64_chk_warn,
__fortify_function __wur ssize_t
pread (int __fd, void *__buf, size_t __nbytes, __off_t __offset)
{
- if (__bos0 (__buf) != (size_t) -1)
+ if (__glibc_objsize0 (__buf) != (size_t) -1)
{
if (!__builtin_constant_p (__nbytes))
- return __pread_chk (__fd, __buf, __nbytes, __offset, __bos0 (__buf));
+ return __pread_chk (__fd, __buf, __nbytes, __offset,
+ __glibc_objsize0 (__buf));
- if ( __nbytes > __bos0 (__buf))
+ if ( __nbytes > __glibc_objsize0 (__buf))
return __pread_chk_warn (__fd, __buf, __nbytes, __offset,
- __bos0 (__buf));
+ __glibc_objsize0 (__buf));
}
return __pread_alias (__fd, __buf, __nbytes, __offset);
}
@@ -92,14 +94,15 @@ pread (int __fd, void *__buf, size_t __nbytes, __off_t __offset)
__fortify_function __wur ssize_t
pread (int __fd, void *__buf, size_t __nbytes, __off64_t __offset)
{
- if (__bos0 (__buf) != (size_t) -1)
+ if (__glibc_objsize0 (__buf) != (size_t) -1)
{
if (!__builtin_constant_p (__nbytes))
- return __pread64_chk (__fd, __buf, __nbytes, __offset, __bos0 (__buf));
+ return __pread64_chk (__fd, __buf, __nbytes, __offset,
+ __glibc_objsize0 (__buf));
- if ( __nbytes > __bos0 (__buf))
+ if ( __nbytes > __glibc_objsize0 (__buf))
return __pread64_chk_warn (__fd, __buf, __nbytes, __offset,
- __bos0 (__buf));
+ __glibc_objsize0 (__buf));
}
return __pread64_alias (__fd, __buf, __nbytes, __offset);
@@ -110,14 +113,15 @@ pread (int __fd, void *__buf, size_t __nbytes, __off64_t __offset)
__fortify_function __wur ssize_t
pread64 (int __fd, void *__buf, size_t __nbytes, __off64_t __offset)
{
- if (__bos0 (__buf) != (size_t) -1)
+ if (__glibc_objsize0 (__buf) != (size_t) -1)
{
if (!__builtin_constant_p (__nbytes))
- return __pread64_chk (__fd, __buf, __nbytes, __offset, __bos0 (__buf));
+ return __pread64_chk (__fd, __buf, __nbytes, __offset,
+ __glibc_objsize0 (__buf));
- if ( __nbytes > __bos0 (__buf))
+ if ( __nbytes > __glibc_objsize0 (__buf))
return __pread64_chk_warn (__fd, __buf, __nbytes, __offset,
- __bos0 (__buf));
+ __glibc_objsize0 (__buf));
}
return __pread64_alias (__fd, __buf, __nbytes, __offset);
@@ -145,13 +149,14 @@ __fortify_function __nonnull ((1, 2)) __wur ssize_t
__NTH (readlink (const char *__restrict __path, char *__restrict __buf,
size_t __len))
{
- if (__bos (__buf) != (size_t) -1)
+ if (__glibc_objsize (__buf) != (size_t) -1)
{
if (!__builtin_constant_p (__len))
- return __readlink_chk (__path, __buf, __len, __bos (__buf));
+ return __readlink_chk (__path, __buf, __len, __glibc_objsize (__buf));
- if ( __len > __bos (__buf))
- return __readlink_chk_warn (__path, __buf, __len, __bos (__buf));
+ if ( __len > __glibc_objsize (__buf))
+ return __readlink_chk_warn (__path, __buf, __len,
+ __glibc_objsize (__buf));
}
return __readlink_alias (__path, __buf, __len);
}
@@ -179,14 +184,15 @@ __fortify_function __nonnull ((2, 3)) __wur ssize_t
__NTH (readlinkat (int __fd, const char *__restrict __path,
char *__restrict __buf, size_t __len))
{
- if (__bos (__buf) != (size_t) -1)
+ if (__glibc_objsize (__buf) != (size_t) -1)
{
if (!__builtin_constant_p (__len))
- return __readlinkat_chk (__fd, __path, __buf, __len, __bos (__buf));
+ return __readlinkat_chk (__fd, __path, __buf, __len,
+ __glibc_objsize (__buf));
- if (__len > __bos (__buf))
+ if (__len > __glibc_objsize (__buf))
return __readlinkat_chk_warn (__fd, __path, __buf, __len,
- __bos (__buf));
+ __glibc_objsize (__buf));
}
return __readlinkat_alias (__fd, __path, __buf, __len);
}
@@ -206,13 +212,13 @@ extern char *__REDIRECT_NTH (__getcwd_chk_warn,
__fortify_function __wur char *
__NTH (getcwd (char *__buf, size_t __size))
{
- if (__bos (__buf) != (size_t) -1)
+ if (__glibc_objsize (__buf) != (size_t) -1)
{
if (!__builtin_constant_p (__size))
- return __getcwd_chk (__buf, __size, __bos (__buf));
+ return __getcwd_chk (__buf, __size, __glibc_objsize (__buf));
- if (__size > __bos (__buf))
- return __getcwd_chk_warn (__buf, __size, __bos (__buf));
+ if (__size > __glibc_objsize (__buf))
+ return __getcwd_chk_warn (__buf, __size, __glibc_objsize (__buf));
}
return __getcwd_alias (__buf, __size);
}
@@ -227,8 +233,8 @@ extern char *__REDIRECT_NTH (__getwd_warn, (char *__buf), getwd)
__fortify_function __nonnull ((1)) __attribute_deprecated__ __wur char *
__NTH (getwd (char *__buf))
{
- if (__bos (__buf) != (size_t) -1)
- return __getwd_chk (__buf, __bos (__buf));
+ if (__glibc_objsize (__buf) != (size_t) -1)
+ return __getwd_chk (__buf, __glibc_objsize (__buf));
return __getwd_warn (__buf);
}
#endif
@@ -248,13 +254,14 @@ extern size_t __REDIRECT_NTH (__confstr_chk_warn,
__fortify_function size_t
__NTH (confstr (int __name, char *__buf, size_t __len))
{
- if (__bos (__buf) != (size_t) -1)
+ if (__glibc_objsize (__buf) != (size_t) -1)
{
if (!__builtin_constant_p (__len))
- return __confstr_chk (__name, __buf, __len, __bos (__buf));
+ return __confstr_chk (__name, __buf, __len, __glibc_objsize (__buf));
- if (__bos (__buf) < __len)
- return __confstr_chk_warn (__name, __buf, __len, __bos (__buf));
+ if (__glibc_objsize (__buf) < __len)
+ return __confstr_chk_warn (__name, __buf, __len,
+ __glibc_objsize (__buf));
}
return __confstr_alias (__name, __buf, __len);
}
@@ -273,13 +280,13 @@ extern int __REDIRECT_NTH (__getgroups_chk_warn,
__fortify_function int
__NTH (getgroups (int __size, __gid_t __list[]))
{
- if (__bos (__list) != (size_t) -1)
+ if (__glibc_objsize (__list) != (size_t) -1)
{
if (!__builtin_constant_p (__size) || __size < 0)
- return __getgroups_chk (__size, __list, __bos (__list));
+ return __getgroups_chk (__size, __list, __glibc_objsize (__list));
- if (__size * sizeof (__gid_t) > __bos (__list))
- return __getgroups_chk_warn (__size, __list, __bos (__list));
+ if (__size * sizeof (__gid_t) > __glibc_objsize (__list))
+ return __getgroups_chk_warn (__size, __list, __glibc_objsize (__list));
}
return __getgroups_alias (__size, __list);
}
@@ -300,13 +307,15 @@ extern int __REDIRECT_NTH (__ttyname_r_chk_warn,
__fortify_function int
__NTH (ttyname_r (int __fd, char *__buf, size_t __buflen))
{
- if (__bos (__buf) != (size_t) -1)
+ if (__glibc_objsize (__buf) != (size_t) -1)
{
if (!__builtin_constant_p (__buflen))
- return __ttyname_r_chk (__fd, __buf, __buflen, __bos (__buf));
+ return __ttyname_r_chk (__fd, __buf, __buflen,
+ __glibc_objsize (__buf));
- if (__buflen > __bos (__buf))
- return __ttyname_r_chk_warn (__fd, __buf, __buflen, __bos (__buf));
+ if (__buflen > __glibc_objsize (__buf))
+ return __ttyname_r_chk_warn (__fd, __buf, __buflen,
+ __glibc_objsize (__buf));
}
return __ttyname_r_alias (__fd, __buf, __buflen);
}
@@ -326,13 +335,14 @@ extern int __REDIRECT (__getlogin_r_chk_warn,
__fortify_function int
getlogin_r (char *__buf, size_t __buflen)
{
- if (__bos (__buf) != (size_t) -1)
+ if (__glibc_objsize (__buf) != (size_t) -1)
{
if (!__builtin_constant_p (__buflen))
- return __getlogin_r_chk (__buf, __buflen, __bos (__buf));
+ return __getlogin_r_chk (__buf, __buflen, __glibc_objsize (__buf));
- if (__buflen > __bos (__buf))
- return __getlogin_r_chk_warn (__buf, __buflen, __bos (__buf));
+ if (__buflen > __glibc_objsize (__buf))
+ return __getlogin_r_chk_warn (__buf, __buflen,
+ __glibc_objsize (__buf));
}
return __getlogin_r_alias (__buf, __buflen);
}
@@ -354,13 +364,14 @@ extern int __REDIRECT_NTH (__gethostname_chk_warn,
__fortify_function int
__NTH (gethostname (char *__buf, size_t __buflen))
{
- if (__bos (__buf) != (size_t) -1)
+ if (__glibc_objsize (__buf) != (size_t) -1)
{
if (!__builtin_constant_p (__buflen))
- return __gethostname_chk (__buf, __buflen, __bos (__buf));
+ return __gethostname_chk (__buf, __buflen, __glibc_objsize (__buf));
- if (__buflen > __bos (__buf))
- return __gethostname_chk_warn (__buf, __buflen, __bos (__buf));
+ if (__buflen > __glibc_objsize (__buf))
+ return __gethostname_chk_warn (__buf, __buflen,
+ __glibc_objsize (__buf));
}
return __gethostname_alias (__buf, __buflen);
}
@@ -384,13 +395,14 @@ extern int __REDIRECT_NTH (__getdomainname_chk_warn,
__fortify_function int
__NTH (getdomainname (char *__buf, size_t __buflen))
{
- if (__bos (__buf) != (size_t) -1)
+ if (__glibc_objsize (__buf) != (size_t) -1)
{
if (!__builtin_constant_p (__buflen))
- return __getdomainname_chk (__buf, __buflen, __bos (__buf));
+ return __getdomainname_chk (__buf, __buflen, __glibc_objsize (__buf));
- if (__buflen > __bos (__buf))
- return __getdomainname_chk_warn (__buf, __buflen, __bos (__buf));
+ if (__buflen > __glibc_objsize (__buf))
+ return __getdomainname_chk_warn (__buf, __buflen,
+ __glibc_objsize (__buf));
}
return __getdomainname_alias (__buf, __buflen);
}