summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2024-05-31 17:36:42 -0400
committerJakob Kaivo <jkk@ung.org>2024-05-31 17:36:42 -0400
commit5da021a62216a1f152f844873a95b2dc4dc1e4bc (patch)
tree687fe805c86d839c8e622d3dfa65bb7dc6b170c1
parentd9d88be07165a22dde3be6b07f77900bfc3efb5c (diff)
fix off-by-one with overlap checking
-rw-r--r--src/_safety.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/_safety.h b/src/_safety.h
index ebfe1acc..8f157b7b 100644
--- a/src/_safety.h
+++ b/src/_safety.h
@@ -75,8 +75,8 @@ extern struct __dangerous {
#define ASSERT_NOOVERLAP(__p1, __l1, __p2, __l2) do { \
char *__s1 = (char*)(__p1); \
char *__s2 = (char*)(__p2); \
- if (((__s1 < __s2) && ((__s1 + (__l1)) >= __s2)) || ((__s1 > __s2) && ((__s2 + (__l2)) >= __s1))) { \
- UNDEFINED("In call to %s(), parameters %s and %s overlap", __func__, #__p1, #__p2); \
+ if (((__s1 < __s2) && ((__s1 + (__l1)) > __s2)) || ((__s1 > __s2) && ((__s2 + (__l2)) > __s1))) { \
+ UNDEFINED("In call to %s(), parameters %s (%p-%p) and %s (%p-%p) overlap", __func__, #__p1, __p1, __s1 + __l1 - 1, #__p2, __p2, __s2 + __l2 - 1); \
} \
} while (0)