From 0784beab029ba53201ef93a601cb8c10d6aaca7f Mon Sep 17 00:00:00 2001 From: sin Date: Thu, 29 Jan 2015 17:55:03 +0000 Subject: Allow dest == src in memcpy() memcpy() needs to accept dest == src for gcc. struct foo a, b; a = a; might be implemented using memcpy(). --- include/string.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/string.h') diff --git a/include/string.h b/include/string.h index e464eab..21e853e 100644 --- a/include/string.h +++ b/include/string.h @@ -20,9 +20,9 @@ __fortify_memcpy(void *__restrict dest, const void *__restrict src, size_t n) if (__builtin_constant_p(n) && n > bos) __memcpy_error(); - /* trap if pointers are overlapping */ - if ((d <= s && d + n > s) || - (s <= d && s + n > d)) + /* trap if pointers are overlapping but not if dest == src */ + if ((d < s && d + n > s) || + (s < d && s + n > d)) __builtin_trap(); if (n > bos) __builtin_trap(); -- cgit v1.3