From debadaa238e90fce897b467a9efefcbbc0155d06 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sun, 23 Sep 2018 00:03:08 -0400 Subject: fix undefined pointer comparison in memmove the comparison must take place in the address space model as an integer type, since comparing pointers that are not pointing into the same array is undefined. the subsequent d=n, algebraically !(-n=s-d-n. --- src/string/memmove.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/string') diff --git a/src/string/memmove.c b/src/string/memmove.c index 27f670e1..f225bb30 100644 --- a/src/string/memmove.c +++ b/src/string/memmove.c @@ -10,7 +10,7 @@ void *memmove(void *dest, const void *src, size_t n) const char *s = src; if (d==s) return d; - if (s+n <= d || d+n <= s) return memcpy(d, s, n); + if ((uintptr_t)s-(uintptr_t)d-n <= -2*n) return memcpy(d, s, n); if (d