commit 3e6704d0be707487d7a9dccfdc75203c7261e11b
parent e3fee64643279c144efd3d6856ed4e818c0d5ca2
Author: jvoisin <julien.voisin@dustri.org>
Date: Sat, 18 Mar 2023 14:01:02 +0100
Make use of __builtin_dynamic_object_size
GCC and Clang provide __builtin_dynamic_object_size
(see documentation: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html),
so we should make use of it when its available.
Diffstat:
10 files changed, 72 insertions(+), 64 deletions(-)
diff --git a/include/fortify-headers.h b/include/fortify-headers.h
@@ -21,4 +21,12 @@
#define _FORTIFY_FN(fn) _FORTIFY_ORIG(__USER_LABEL_PREFIX__,fn); \
extern __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__))
+
+/* Use __builtin_dynamic_object_size with _FORTIFY_SOURCE>2, if available. */
+#if _FORTIFY_SOURCE > 2 && defined __has_builtin && __has_builtin (__builtin_dynamic_object_size)
+#define __bos(ptr, type) __builtin_dynamic_object_size (ptr, type)
+#else
+#define __bos(ptr, type) __builtin_object_size (ptr, type)
+#endif
+
#endif
diff --git a/include/poll.h b/include/poll.h
@@ -32,7 +32,7 @@ extern "C" {
_FORTIFY_FN(poll) int poll(struct pollfd *__f, nfds_t __n, int __s)
{
- __typeof__(sizeof 0) __b = __builtin_object_size(__f, 0);
+ __typeof__(sizeof 0) __b = __bos(__f, 0);
if (__n > __b / sizeof(struct pollfd))
__builtin_trap();
@@ -44,7 +44,7 @@ _FORTIFY_FN(poll) int poll(struct pollfd *__f, nfds_t __n, int __s)
_FORTIFY_FN(ppoll) int ppoll(struct pollfd *__f, nfds_t __n, const struct timespec *__s,
const sigset_t *__m)
{
- __typeof__(sizeof 0) __b = __builtin_object_size(__f, 0);
+ __typeof__(sizeof 0) __b = __bos(__f, 0);
if (__n > __b / sizeof(struct pollfd))
__builtin_trap();
diff --git a/include/stdio.h b/include/stdio.h
@@ -38,7 +38,7 @@ extern "C" {
_FORTIFY_FN(fgets) char *fgets(char *__s, int __n, FILE *__f)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if ((size_t)__n > __b)
__builtin_trap();
@@ -47,7 +47,7 @@ _FORTIFY_FN(fgets) char *fgets(char *__s, int __n, FILE *__f)
_FORTIFY_FN(fread) size_t fread(void *__d, size_t __n, size_t __m, FILE *__f)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
if (__n != 0 && (__n * __m) / __n != __m)
__builtin_trap();
@@ -58,7 +58,7 @@ _FORTIFY_FN(fread) size_t fread(void *__d, size_t __n, size_t __m, FILE *__f)
_FORTIFY_FN(fwrite) size_t fwrite(const void *__d, size_t __n, size_t __m, FILE *__f)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
if (__n != 0 && (__n * __m) / __n != __m)
__builtin_trap();
@@ -70,7 +70,7 @@ _FORTIFY_FN(fwrite) size_t fwrite(const void *__d, size_t __n, size_t __m, FILE
_FORTIFY_FN(vsnprintf) int vsnprintf(char *__s, size_t __n, const char *__f,
__builtin_va_list __v)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__n > __b)
__builtin_trap();
@@ -79,7 +79,7 @@ _FORTIFY_FN(vsnprintf) int vsnprintf(char *__s, size_t __n, const char *__f,
_FORTIFY_FN(vsprintf) int vsprintf(char *__s, const char *__f, __builtin_va_list __v)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
int __r;
if (__b != (size_t)-1) {
@@ -94,7 +94,7 @@ _FORTIFY_FN(vsprintf) int vsprintf(char *__s, const char *__f, __builtin_va_list
_FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n, const char *__f, ...)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__n > __b)
__builtin_trap();
@@ -103,7 +103,7 @@ _FORTIFY_FN(snprintf) int snprintf(char *__s, size_t __n, const char *__f, ...)
_FORTIFY_FN(sprintf) int sprintf(char *__s, const char *__f, ...)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
int __r;
if (__b != (size_t)-1) {
diff --git a/include/stdlib.h b/include/stdlib.h
@@ -42,7 +42,7 @@ _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r)
#ifndef PATH_MAX
#error PATH_MAX unset. A fortified realpath will not work.
#else
- if (__r && PATH_MAX > __builtin_object_size(__r, 2)) {
+ if (__r && PATH_MAX > __bos(__r, 2)) {
char __buf[PATH_MAX], *__ret;
size_t __l;
@@ -50,7 +50,7 @@ _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r)
if (!__ret)
return NULL;
__l = __builtin_strlen(__ret) + 1;
- if (__l > __builtin_object_size(__r, 0))
+ if (__l > __bos(__r, 0))
__builtin_trap();
__builtin_memcpy(__r, __ret, __l);
return __r;
diff --git a/include/string.h b/include/string.h
@@ -38,8 +38,8 @@ extern "C" {
_FORTIFY_FN(memcpy) void *memcpy(void *__od, const void *__os, size_t __n)
{
- size_t __bd = __builtin_object_size(__od, 0);
- size_t __bs = __builtin_object_size(__os, 0);
+ size_t __bd = __bos(__od, 0);
+ size_t __bs = __bos(__os, 0);
char *__d = (char *)__od;
const char *__s = (const char *)__os;
@@ -55,8 +55,8 @@ _FORTIFY_FN(memcpy) void *memcpy(void *__od, const void *__os, size_t __n)
_FORTIFY_FN(memmove) void *memmove(void *__d, const void *__s, size_t __n)
{
- size_t __bd = __builtin_object_size(__d, 0);
- size_t __bs = __builtin_object_size(__s, 0);
+ size_t __bd = __bos(__d, 0);
+ size_t __bs = __bos(__s, 0);
if (__n > __bd || __n > __bs)
__builtin_trap();
@@ -65,7 +65,7 @@ _FORTIFY_FN(memmove) void *memmove(void *__d, const void *__s, size_t __n)
_FORTIFY_FN(memset) void *memset(void *__d, int __c, size_t __n)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
if (__n > __b)
__builtin_trap();
@@ -78,7 +78,7 @@ _FORTIFY_FN(memset) void *memset(void *__d, int __c, size_t __n)
#undef stpcpy
_FORTIFY_FN(stpcpy) char *stpcpy(char *__d, const char *__s)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
if (strlen(__s) + 1 > __b)
__builtin_trap();
@@ -88,7 +88,7 @@ _FORTIFY_FN(stpcpy) char *stpcpy(char *__d, const char *__s)
#undef stpncpy
_FORTIFY_FN(stpncpy) char *stpncpy(char *__d, const char *__s, size_t __n)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
if (__n > __b && strlen(__s) + 1 > __b)
__builtin_trap();
@@ -98,7 +98,7 @@ _FORTIFY_FN(stpncpy) char *stpncpy(char *__d, const char *__s, size_t __n)
_FORTIFY_FN(strcat) char *strcat(char *__d, const char *__s)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
if (strlen(__s) + strlen(__d) + 1 > __b)
__builtin_trap();
@@ -107,7 +107,7 @@ _FORTIFY_FN(strcat) char *strcat(char *__d, const char *__s)
_FORTIFY_FN(strcpy) char *strcpy(char *__d, const char *__s)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
if (strlen(__s) + 1 > __b)
__builtin_trap();
@@ -116,7 +116,7 @@ _FORTIFY_FN(strcpy) char *strcpy(char *__d, const char *__s)
_FORTIFY_FN(strncat) char *strncat(char *__d, const char *__s, size_t __n)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
size_t __sl, __dl;
if (__n > __b) {
@@ -132,7 +132,7 @@ _FORTIFY_FN(strncat) char *strncat(char *__d, const char *__s, size_t __n)
_FORTIFY_FN(strncpy) char *strncpy(char *__d, const char *__s, size_t __n)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
if (__n > __b)
__builtin_trap();
@@ -143,8 +143,8 @@ _FORTIFY_FN(strncpy) char *strncpy(char *__d, const char *__s, size_t __n)
#undef mempcpy
_FORTIFY_FN(mempcpy) void *mempcpy(void *__d, const void *__s, size_t __n)
{
- size_t __bd = __builtin_object_size(__d, 0);
- size_t __bs = __builtin_object_size(__s, 0);
+ size_t __bd = __bos(__d, 0);
+ size_t __bs = __bos(__s, 0);
if (__n > __bd || __n > __bs)
__builtin_trap();
@@ -157,7 +157,7 @@ _FORTIFY_FN(mempcpy) void *mempcpy(void *__d, const void *__s, size_t __n)
#undef strlcpy
_FORTIFY_FN(strlcat) size_t strlcat(char *__d, const char *__s, size_t __n)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
if (__n > __b)
__builtin_trap();
@@ -166,7 +166,7 @@ _FORTIFY_FN(strlcat) size_t strlcat(char *__d, const char *__s, size_t __n)
_FORTIFY_FN(strlcpy) size_t strlcpy(char *__d, const char *__s, size_t __n)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
if (__n > __b)
__builtin_trap();
diff --git a/include/strings.h b/include/strings.h
@@ -32,8 +32,8 @@ extern "C" {
#undef bzero
_FORTIFY_FN(bcopy) void bcopy(const void *__s, void *__d, size_t __n)
{
- size_t __bd = __builtin_object_size(__d, 0);
- size_t __bs = __builtin_object_size(__s, 0);
+ size_t __bd = __bos(__d, 0);
+ size_t __bs = __bos(__s, 0);
if (__n > __bd || __n > __bs)
__builtin_trap();
@@ -42,7 +42,7 @@ _FORTIFY_FN(bcopy) void bcopy(const void *__s, void *__d, size_t __n)
_FORTIFY_FN(bzero) void bzero(void *__s, size_t __n)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__n > __b)
__builtin_trap();
diff --git a/include/sys/select.h b/include/sys/select.h
@@ -30,7 +30,7 @@ extern "C" {
static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__))
void __fortify_FD_CLR(int __f, fd_set *__s)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__f < 0 || __f >= FD_SETSIZE || __b < sizeof(fd_set))
__builtin_trap();
@@ -40,7 +40,7 @@ void __fortify_FD_CLR(int __f, fd_set *__s)
static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__))
void __fortify_FD_SET(int __f, fd_set *__s)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__f < 0 || __f >= FD_SETSIZE || __b < sizeof(fd_set))
__builtin_trap();
diff --git a/include/sys/socket.h b/include/sys/socket.h
@@ -35,7 +35,7 @@ extern "C" {
_FORTIFY_FN(recv) ssize_t recv(int __f, void *__s, size_t __n, int __fl)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__n > __b)
__builtin_trap();
@@ -45,7 +45,7 @@ _FORTIFY_FN(recv) ssize_t recv(int __f, void *__s, size_t __n, int __fl)
_FORTIFY_FN(recvfrom) ssize_t recvfrom(int __f, void *__s, size_t __n, int __fl,
struct sockaddr *__a, socklen_t *__l)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__n > __b)
__builtin_trap();
@@ -54,7 +54,7 @@ _FORTIFY_FN(recvfrom) ssize_t recvfrom(int __f, void *__s, size_t __n, int __fl,
_FORTIFY_FN(send) ssize_t send(int __f, const void *__s, size_t __n, int __fl)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__n > __b)
__builtin_trap();
@@ -64,7 +64,7 @@ _FORTIFY_FN(send) ssize_t send(int __f, const void *__s, size_t __n, int __fl)
_FORTIFY_FN(sendto) ssize_t sendto(int __f, const void *__s, size_t __n, int __fl,
const struct sockaddr *__a, socklen_t __l)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__n > __b)
__builtin_trap();
diff --git a/include/unistd.h b/include/unistd.h
@@ -42,7 +42,7 @@ extern "C" {
_FORTIFY_FN(confstr) size_t confstr(int __n, char *__s, size_t __l)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
size_t __r = __orig_confstr(__n, __s, __b > __l ? __l : __b);
if (__l > __b && __r > __b)
@@ -52,7 +52,7 @@ _FORTIFY_FN(confstr) size_t confstr(int __n, char *__s, size_t __l)
_FORTIFY_FN(getcwd) char *getcwd(char *__s, size_t __l)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__l > __b)
__builtin_trap();
@@ -63,7 +63,7 @@ _FORTIFY_FN(getcwd) char *getcwd(char *__s, size_t __l)
#undef getdomainname
_FORTIFY_FN(getdomainname) int getdomainname(char *__s, size_t __l)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__l > __b)
__builtin_trap();
@@ -73,7 +73,7 @@ _FORTIFY_FN(getdomainname) int getdomainname(char *__s, size_t __l)
_FORTIFY_FN(getgroups) int getgroups(int __l, gid_t *__s)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__l > 0 && (unsigned)__l > __b / sizeof(gid_t))
__builtin_trap();
@@ -82,7 +82,7 @@ _FORTIFY_FN(getgroups) int getgroups(int __l, gid_t *__s)
_FORTIFY_FN(gethostname) int gethostname(char *__s, size_t __l)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__l > __b)
__builtin_trap();
@@ -91,7 +91,7 @@ _FORTIFY_FN(gethostname) int gethostname(char *__s, size_t __l)
_FORTIFY_FN(getlogin_r) int getlogin_r(char *__s, size_t __l)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__l > __b)
__builtin_trap();
@@ -100,7 +100,7 @@ _FORTIFY_FN(getlogin_r) int getlogin_r(char *__s, size_t __l)
_FORTIFY_FN(pread) ssize_t pread(int __f, void *__s, size_t __n, off_t __o)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__n > __b)
__builtin_trap();
@@ -109,7 +109,7 @@ _FORTIFY_FN(pread) ssize_t pread(int __f, void *__s, size_t __n, off_t __o)
_FORTIFY_FN(read) ssize_t read(int __f, void *__s, size_t __n)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__n > __b)
__builtin_trap();
@@ -118,7 +118,7 @@ _FORTIFY_FN(read) ssize_t read(int __f, void *__s, size_t __n)
_FORTIFY_FN(readlink) ssize_t readlink(const char *__p, char *__s, size_t __n)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__n > __b)
__builtin_trap();
@@ -127,7 +127,7 @@ _FORTIFY_FN(readlink) ssize_t readlink(const char *__p, char *__s, size_t __n)
_FORTIFY_FN(readlinkat) ssize_t readlinkat(int __f, const char *__p, char *__s, size_t __n)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__n > __b)
__builtin_trap();
@@ -136,7 +136,7 @@ _FORTIFY_FN(readlinkat) ssize_t readlinkat(int __f, const char *__p, char *__s,
_FORTIFY_FN(ttyname_r) int ttyname_r(int __f, char *__s, size_t __n)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__n > __b)
__builtin_trap();
@@ -145,7 +145,7 @@ _FORTIFY_FN(ttyname_r) int ttyname_r(int __f, char *__s, size_t __n)
_FORTIFY_FN(write) ssize_t write(int __f, const void *__s, size_t __n)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__n > __b)
__builtin_trap();
diff --git a/include/wchar.h b/include/wchar.h
@@ -57,7 +57,7 @@ extern "C" {
_FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t *__s, int __n, FILE *__f)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if ((size_t)__n > __b / sizeof(wchar_t))
__builtin_trap();
@@ -70,7 +70,7 @@ _FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t *__s, int __n, FILE *__f)
_FORTIFY_FN(mbsnrtowcs) size_t mbsnrtowcs(wchar_t *__d, const char **__s, size_t __n,
size_t __wn, mbstate_t *__st)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
size_t __r;
if (__wn > __n / sizeof(wchar_t)) {
@@ -90,7 +90,7 @@ _FORTIFY_FN(mbsnrtowcs) size_t mbsnrtowcs(wchar_t *__d, const char **__s, size_t
_FORTIFY_FN(mbsrtowcs) size_t mbsrtowcs(wchar_t *__d, const char **__s, size_t __wn,
mbstate_t *__st)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
size_t __r;
__b /= sizeof(wchar_t);
@@ -102,7 +102,7 @@ _FORTIFY_FN(mbsrtowcs) size_t mbsrtowcs(wchar_t *__d, const char **__s, size_t _
_FORTIFY_FN(mbstowcs) size_t mbstowcs(wchar_t *__ws, const char *__s, size_t __wn)
{
- size_t __b = __builtin_object_size(__ws, 0);
+ size_t __b = __bos(__ws, 0);
if (__ws && __wn > __b / sizeof(wchar_t))
__builtin_trap();
@@ -111,14 +111,14 @@ _FORTIFY_FN(mbstowcs) size_t mbstowcs(wchar_t *__ws, const char *__s, size_t __w
_FORTIFY_FN(wcrtomb) size_t wcrtomb(char *__s, wchar_t __w, mbstate_t *__st)
{
- if (__s && MB_LEN_MAX > __builtin_object_size(__s, 2)) {
+ if (__s && MB_LEN_MAX > __bos(__s, 2)) {
char __buf[MB_LEN_MAX];
size_t __r;
__r = __orig_wcrtomb(__buf, __w, __st);
if (__r == (size_t)-1)
return __r;
- if (__r > __builtin_object_size(__s, 0))
+ if (__r > __bos(__s, 0))
__builtin_trap();
__builtin_memcpy(__s, __buf, __r);
return __r;
@@ -128,7 +128,7 @@ _FORTIFY_FN(wcrtomb) size_t wcrtomb(char *__s, wchar_t __w, mbstate_t *__st)
_FORTIFY_FN(wcscat) wchar_t *wcscat(wchar_t *__d, const wchar_t *__s)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
if (wcslen(__s) + wcslen(__d) + 1 > __b / sizeof(wchar_t))
__builtin_trap();
@@ -137,7 +137,7 @@ _FORTIFY_FN(wcscat) wchar_t *wcscat(wchar_t *__d, const wchar_t *__s)
_FORTIFY_FN(wcscpy) wchar_t *wcscpy(wchar_t *__d, const wchar_t *__s)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
if (wcslen(__s) + 1 > __b / sizeof(wchar_t))
__builtin_trap();
@@ -146,7 +146,7 @@ _FORTIFY_FN(wcscpy) wchar_t *wcscpy(wchar_t *__d, const wchar_t *__s)
_FORTIFY_FN(wcsncat) wchar_t *wcsncat(wchar_t *__d, const wchar_t *__s, size_t __n)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
size_t __sl, __dl;
if (__n > __b / sizeof(wchar_t)) {
@@ -162,7 +162,7 @@ _FORTIFY_FN(wcsncat) wchar_t *wcsncat(wchar_t *__d, const wchar_t *__s, size_t _
_FORTIFY_FN(wcsncpy) wchar_t *wcsncpy(wchar_t *__d, const wchar_t *__s, size_t __n)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
if (__n > __b / sizeof(wchar_t))
__builtin_trap();
@@ -175,7 +175,7 @@ _FORTIFY_FN(wcsncpy) wchar_t *wcsncpy(wchar_t *__d, const wchar_t *__s, size_t _
_FORTIFY_FN(wcsnrtombs) size_t wcsnrtombs(char *__d, const wchar_t **__s, size_t __wn,
size_t __n, mbstate_t *__st)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
size_t __r;
if (__wn > __n / sizeof(wchar_t)) {
@@ -195,7 +195,7 @@ _FORTIFY_FN(wcsnrtombs) size_t wcsnrtombs(char *__d, const wchar_t **__s, size_t
_FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char *__d, const wchar_t **__s, size_t __n,
mbstate_t *__st)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
size_t __r;
__r = __orig_wcsrtombs(__d, __s, __n > __b ? __b : __n, __st);
@@ -206,7 +206,7 @@ _FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char *__d, const wchar_t **__s, size_t _
_FORTIFY_FN(wcstombs) size_t wcstombs(char *__s, const wchar_t *__ws, size_t __n)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__s && __n > __b)
__builtin_trap();
@@ -215,7 +215,7 @@ _FORTIFY_FN(wcstombs) size_t wcstombs(char *__s, const wchar_t *__ws, size_t __n
_FORTIFY_FN(wctomb) int wctomb(char *__s, wchar_t __w)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__s && MB_LEN_MAX > __b && MB_CUR_MAX > __b)
__builtin_trap();
@@ -224,7 +224,7 @@ _FORTIFY_FN(wctomb) int wctomb(char *__s, wchar_t __w)
_FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t *__d, const wchar_t *__s, size_t __n)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
if (__n > __b / sizeof(wchar_t))
__builtin_trap();
@@ -233,7 +233,7 @@ _FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t *__d, const wchar_t *__s, size_t _
_FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t *__d, const wchar_t *__s, size_t __n)
{
- size_t __b = __builtin_object_size(__d, 0);
+ size_t __b = __bos(__d, 0);
if (__n > __b / sizeof(wchar_t))
__builtin_trap();
@@ -242,7 +242,7 @@ _FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t *__d, const wchar_t *__s, size_t
_FORTIFY_FN(wmemset) wchar_t *wmemset(wchar_t *__s, wchar_t __c, size_t __n)
{
- size_t __b = __builtin_object_size(__s, 0);
+ size_t __b = __bos(__s, 0);
if (__n > __b / sizeof(wchar_t))
__builtin_trap();