This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Remove CHECK_BOUNDS_LOW and CHECK_BOUNDS_HIGH for C code
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>
- Date: Mon, 4 Feb 2013 23:59:20 +0000
- Subject: Remove CHECK_BOUNDS_LOW and CHECK_BOUNDS_HIGH for C code
Continuing the removal of the bitrotten bounded-pointers code, this
patch removes the C macros CHECK_BOUNDS_LOW and CHECK_BOUNDS_HIGH in
bp-checks.h, along with their only uses. (Note that there are macros
with the same names in bp-asm.h for various architectures, used in .S
files, which this patch does not touch.)
Tested x86_64.
2013-02-04 Joseph Myers <joseph@codesourcery.com>
[BZ #13550]
* sysdeps/generic/bp-checks.h (CHECK_BOUNDS_LOW): Remove all
definitions.
(CHECK_BOUNDS_HIGH): Likewise.
* string/strcpy.c: Do not include <bp-checks.h>.
(strcpy): Do not use CHECK_BOUNDS_LOW and CHECK_BOUNDS_HIGH.
diff --git a/string/strcpy.c b/string/strcpy.c
index a2bb8ef..9b713dc 100644
--- a/string/strcpy.c
+++ b/string/strcpy.c
@@ -18,7 +18,6 @@
#include <stddef.h>
#include <string.h>
#include <memcopy.h>
-#include <bp-checks.h>
#undef strcpy
@@ -29,8 +28,8 @@ strcpy (dest, src)
const char *src;
{
char c;
- char *__unbounded s = (char *__unbounded) CHECK_BOUNDS_LOW (src);
- const ptrdiff_t off = CHECK_BOUNDS_LOW (dest) - s - 1;
+ char *__unbounded s = (char *__unbounded) src;
+ const ptrdiff_t off = dest - s - 1;
size_t n;
do
@@ -41,8 +40,6 @@ strcpy (dest, src)
while (c != '\0');
n = s - src;
- (void) CHECK_BOUNDS_HIGH (src + n);
- (void) CHECK_BOUNDS_HIGH (dest + n);
return dest;
}
diff --git a/sysdeps/generic/bp-checks.h b/sysdeps/generic/bp-checks.h
index 13d00ca..618497c 100644
--- a/sysdeps/generic/bp-checks.h
+++ b/sysdeps/generic/bp-checks.h
@@ -24,16 +24,6 @@
# define BOUNDS_VIOLATED (__builtin_trap (), 0)
-/* Verify that pointer's value >= low. Return pointer value. */
-# define CHECK_BOUNDS_LOW(ARG) \
- (((__ptrvalue (ARG) < __ptrlow (ARG)) && BOUNDS_VIOLATED), \
- __ptrvalue (ARG))
-
-/* Verify that pointer's value < high. Return pointer value. */
-# define CHECK_BOUNDS_HIGH(ARG) \
- (((__ptrvalue (ARG) > __ptrhigh (ARG)) && BOUNDS_VIOLATED), \
- __ptrvalue (ARG))
-
# define _CHECK_N(ARG, N, COND) \
(((COND) \
&& (__ptrvalue (ARG) < __ptrlow (ARG) \
@@ -56,8 +46,6 @@
/* Do nothing if not compiling with -fbounded-pointers. */
# define BOUNDS_VIOLATED
-# define CHECK_BOUNDS_LOW(ARG) (ARG)
-# define CHECK_BOUNDS_HIGH(ARG) (ARG)
# define CHECK_1(ARG) (ARG)
# define CHECK_1_NULL_OK(ARG) (ARG)
# define CHECK_N(ARG, N) (ARG)
--
Joseph S. Myers
joseph@codesourcery.com