From b2c20e6c16278fe556ce4c4ff7d3b146b3a8f009 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 11 Sep 2023 20:23:12 +0200 Subject: Factorize overlap checks into a macro --- include/fortify-headers.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/fortify-headers.h') diff --git a/include/fortify-headers.h b/include/fortify-headers.h index 5be4271..3eaed7c 100644 --- a/include/fortify-headers.h +++ b/include/fortify-headers.h @@ -123,6 +123,15 @@ #endif /* __has_attribute */ +//TODO(jvoisin) Add a check for overflows +/* check if pointers are overlapping but not if dst == src, + * since gcc seems to like to generate code that relies on dst == src */ +#define __fh_overlap(a, b, l) \ + ( \ + ((a) < (b) && (b) < (a) + (size_t)(l)) \ + || ((b) < (a) && (a) < (b) + (size_t)(l)) \ + ) + /* * We're not making use of C23's since: * - there is no elegant way to make it ignore the results. -- cgit v1.3