From: Szabolcs Nagy Date: Mon, 12 Jul 2021 12:06:40 +0000 (+0100) Subject: cheri: fix qsort for capabilities X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=159a76a8dd93700cc5a8039e7483836d86974ce2;p=thirdparty%2Fglibc.git cheri: fix qsort for capabilities On capability targets avoid copying pointers via unsigned long. --- diff --git a/stdlib/msort.c b/stdlib/msort.c index cbe9a4a8fdb..43222e6c9a7 100644 --- a/stdlib/msort.c +++ b/stdlib/msort.c @@ -289,6 +289,10 @@ __qsort_r (void *b, size_t n, size_t s, __compar_d_fn_t cmp, void *arg) && ((char *) b - (char *) 0) % __alignof__ (uint64_t) == 0) p.var = 1; else if ((s & (sizeof (unsigned long) - 1)) == 0 +#ifdef __CHERI_PURE_CAPABILITY__ + && ((char *) b - (char *) 0) + % __alignof__ (void *) != 0 +#endif && ((char *) b - (char *) 0) % __alignof__ (unsigned long) == 0) p.var = 2;