summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/fortify-headers.h6
-rw-r--r--include/string.h10
2 files changed, 8 insertions, 8 deletions
diff --git a/include/fortify-headers.h b/include/fortify-headers.h
index 9831a33..d75ff43 100644
--- a/include/fortify-headers.h
+++ b/include/fortify-headers.h
@@ -135,10 +135,10 @@
135//TODO(jvoisin) Add a check for overflows 135//TODO(jvoisin) Add a check for overflows
136/* check if pointers are overlapping but not if dst == src, 136/* check if pointers are overlapping but not if dst == src,
137 * since gcc seems to like to generate code that relies on dst == src */ 137 * since gcc seems to like to generate code that relies on dst == src */
138#define __fh_overlap(a, b, l) \ 138#define __fh_overlap(a, len_a, b, len_b) \
139 ( \ 139 ( \
140 ((a) < (b) && (b) < (a) + (__fh_size_t)(l)) \ 140 ((a) < (b) && (b) < (a) + (__fh_size_t)(len_a)) \
141 || ((b) < (a) && (a) < (b) + (__fh_size_t)(l)) \ 141 || ((b) < (a) && (a) < (b) + (__fh_size_t)(len_b)) \
142 ) 142 )
143 143
144/* 144/*
diff --git a/include/string.h b/include/string.h
index 925e572..9cb0598 100644
--- a/include/string.h
+++ b/include/string.h
@@ -56,7 +56,7 @@ __error_if((__fh_bos(__od, 0) < __n), "'memcpy' called with `n` bigger than the
56 char *__d = (char *)__od; 56 char *__d = (char *)__od;
57 const char *__s = (const char *)__os; 57 const char *__s = (const char *)__os;
58 58
59 if __fh_overlap(__d, __s, __n) 59 if __fh_overlap(__d, __bd, __s, __n)
60 __builtin_trap(); 60 __builtin_trap();
61 if (__n > __bd || __n > __bs) 61 if (__n > __bd || __n > __bs)
62 __builtin_trap(); 62 __builtin_trap();
@@ -166,11 +166,11 @@ _FORTIFY_FN(stpcpy) char *stpcpy(char * _FORTIFY_POS0 __d, const char *__s)
166 return __builtin___stpcpy_chk(__d, __s, __fh_bos(__d, 0)); 166 return __builtin___stpcpy_chk(__d, __s, __fh_bos(__d, 0));
167#else 167#else
168 __fh_size_t __n = strlen(__s) + 1; 168 __fh_size_t __n = strlen(__s) + 1;
169 __fh_size_t __b = __fh_bos(__d, 0);
169 170
170 if (__fh_overlap(__d, __s, __n)) 171 if (__fh_overlap(__d, __b, __s, __n))
171 __builtin_trap(); 172 __builtin_trap();
172 173
173 __fh_size_t __b = __fh_bos(__d, 0);
174 if (__n > __b) 174 if (__n > __b)
175 __builtin_trap(); 175 __builtin_trap();
176 return __orig_stpcpy(__d, __s); 176 return __orig_stpcpy(__d, __s);
@@ -236,11 +236,11 @@ _FORTIFY_FN(strcpy) char *strcpy(char * _FORTIFY_POS0 __d, const char *__s)
236 return __builtin___strcpy_chk(__d, __s, __fh_bos(__d, 0)); 236 return __builtin___strcpy_chk(__d, __s, __fh_bos(__d, 0));
237#else 237#else
238 __fh_size_t __n = strlen(__s) + 1; 238 __fh_size_t __n = strlen(__s) + 1;
239 __fh_size_t __b = __fh_bos(__d, 0);
239 240
240 if (__fh_overlap(__d, __s, __n)) 241 if (__fh_overlap(__d, __b, __s, __n))
241 __builtin_trap(); 242 __builtin_trap();
242 243
243 __fh_size_t __b = __fh_bos(__d, 0);
244 if (__n > __b) 244 if (__n > __b)
245 __builtin_trap(); 245 __builtin_trap();
246 return __orig_strcpy(__d, __s); 246 return __orig_strcpy(__d, __s);