about summary refs log tree commit diff
path: root/stdlib
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 /stdlib
parent2a3224c53653214cbba2ec23424702193c80ea3b (diff)
downloadglibc-f9de8bfe1a731c309b91d175b4f6f4aeb786effa.tar.gz
glibc-f9de8bfe1a731c309b91d175b4f6f4aeb786effa.tar.xz
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 'stdlib')
-rw-r--r--stdlib/bits/stdlib.h42
1 files changed, 24 insertions, 18 deletions
diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h
index 9134d3f36b..b495cd6929 100644
--- a/stdlib/bits/stdlib.h
+++ b/stdlib/bits/stdlib.h
@@ -36,13 +36,14 @@ extern char *__REDIRECT_NTH (__realpath_chk_warn,
 __fortify_function __wur char *
 __NTH (realpath (const char *__restrict __name, char *__restrict __resolved))
 {
-  if (__bos (__resolved) != (size_t) -1)
+  if (__glibc_objsize (__resolved) != (size_t) -1)
     {
 #if defined _LIBC_LIMITS_H_ && defined PATH_MAX
-      if (__bos (__resolved) < PATH_MAX)
-	return __realpath_chk_warn (__name, __resolved, __bos (__resolved));
+      if (__glibc_objsize (__resolved) < PATH_MAX)
+	return __realpath_chk_warn (__name, __resolved,
+				    __glibc_objsize (__resolved));
 #endif
-      return __realpath_chk (__name, __resolved, __bos (__resolved));
+      return __realpath_chk (__name, __resolved, __glibc_objsize (__resolved));
     }
 
   return __realpath_alias (__name, __resolved);
@@ -64,12 +65,14 @@ extern int __REDIRECT_NTH (__ptsname_r_chk_warn,
 __fortify_function int
 __NTH (ptsname_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 __ptsname_r_chk (__fd, __buf, __buflen, __bos (__buf));
-      if (__buflen > __bos (__buf))
-	return __ptsname_r_chk_warn (__fd, __buf, __buflen, __bos (__buf));
+	return __ptsname_r_chk (__fd, __buf, __buflen,
+				__glibc_objsize (__buf));
+      if (__buflen > __glibc_objsize (__buf))
+	return __ptsname_r_chk_warn (__fd, __buf, __buflen,
+				     __glibc_objsize (__buf));
     }
   return __ptsname_r_alias (__fd, __buf, __buflen);
 }
@@ -90,8 +93,9 @@ __NTH (wctomb (char *__s, wchar_t __wchar))
 #if defined MB_LEN_MAX && MB_LEN_MAX != __STDLIB_MB_LEN_MAX
 # error "Assumed value of MB_LEN_MAX wrong"
 #endif
-  if (__bos (__s) != (size_t) -1 && __STDLIB_MB_LEN_MAX > __bos (__s))
-    return __wctomb_chk (__s, __wchar, __bos (__s));
+  if (__glibc_objsize (__s) != (size_t) -1
+      && __STDLIB_MB_LEN_MAX > __glibc_objsize (__s))
+    return __wctomb_chk (__s, __wchar, __glibc_objsize (__s));
   return __wctomb_alias (__s, __wchar);
 }
 
@@ -116,15 +120,16 @@ __fortify_function size_t
 __NTH (mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src,
 		 size_t __len))
 {
-  if (__bos (__dst) != (size_t) -1)
+  if (__glibc_objsize (__dst) != (size_t) -1)
     {
       if (!__builtin_constant_p (__len))
 	return __mbstowcs_chk (__dst, __src, __len,
-			       __bos (__dst) / sizeof (wchar_t));
+			       __glibc_objsize (__dst) / sizeof (wchar_t));
 
-      if (__len > __bos (__dst) / sizeof (wchar_t))
+      if (__len > __glibc_objsize (__dst) / sizeof (wchar_t))
 	return __mbstowcs_chk_warn (__dst, __src, __len,
-				     __bos (__dst) / sizeof (wchar_t));
+				    (__glibc_objsize (__dst)
+				     / sizeof (wchar_t)));
     }
   return __mbstowcs_alias (__dst, __src, __len);
 }
@@ -149,12 +154,13 @@ __fortify_function size_t
 __NTH (wcstombs (char *__restrict __dst, const wchar_t *__restrict __src,
 		 size_t __len))
 {
-  if (__bos (__dst) != (size_t) -1)
+  if (__glibc_objsize (__dst) != (size_t) -1)
     {
       if (!__builtin_constant_p (__len))
-	return __wcstombs_chk (__dst, __src, __len, __bos (__dst));
-      if (__len > __bos (__dst))
-	return __wcstombs_chk_warn (__dst, __src, __len, __bos (__dst));
+	return __wcstombs_chk (__dst, __src, __len, __glibc_objsize (__dst));
+      if (__len > __glibc_objsize (__dst))
+	return __wcstombs_chk_warn (__dst, __src, __len,
+				    __glibc_objsize (__dst));
     }
   return __wcstombs_alias (__dst, __src, __len);
 }