From fdaf78656fb6cc7caeb7b4e37068e8a8bf4dc639 Mon Sep 17 00:00:00 2001 From: Wilco Dijkstra Date: Fri, 10 Jun 2022 17:13:29 +0100 Subject: Add bounds check to __libc_ifunc_impl_list Add a proper bounds check to __libc_ifunc_impl_list. This makes MAX_IFUNC redundant and fixes several targets that will write outside the array. To avoid unnecessary large diffs, pass the maximum in the argument 'i' to IFUNC_IMPL_ADD - 'max' can be used in new ifunc definitions and existing ones can be updated if desired. Passes buildmanyglibc. Reviewed-by: Adhemerval Zanella --- sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sysdeps/sparc/sparc64') diff --git a/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c b/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c index 9be12f9130..918eb69a03 100644 --- a/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c +++ b/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c @@ -30,7 +30,7 @@ size_t __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, size_t max) { - size_t i = 0; + size_t i = max; int hwcap; hwcap = GLRO(dl_hwcap); @@ -75,5 +75,5 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __memmove_niagara7) IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_ultra1)); - return i; + return 0; } -- cgit 1.4.1