]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
cheri: fix qsort for capabilities
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Mon, 12 Jul 2021 12:06:40 +0000 (13:06 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Fri, 5 Aug 2022 18:45:19 +0000 (19:45 +0100)
On capability targets avoid copying pointers via unsigned long.

stdlib/msort.c

index cbe9a4a8fdb38113a4c18976c9f297be103d458f..43222e6c9a77ac48e97984e9499dd2730483cf23 100644 (file)
@@ -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;