about summary refs log tree commit diff
path: root/sysdeps/sparc
diff options
context:
space:
mode:
authorWilco Dijkstra <wilco.dijkstra@arm.com>2022-06-10 17:13:29 +0100
committerWilco Dijkstra <wdijkstr@arm.com>2022-06-10 17:13:29 +0100
commitfdaf78656fb6cc7caeb7b4e37068e8a8bf4dc639 (patch)
tree05302f7351e2b505af1d50d165bbbe371123d15d /sysdeps/sparc
parentf107b7b30d815f191181617e2c14f21e6af4ddcf (diff)
downloadglibc-fdaf78656fb6cc7caeb7b4e37068e8a8bf4dc639.tar.gz
glibc-fdaf78656fb6cc7caeb7b4e37068e8a8bf4dc639.tar.xz
glibc-fdaf78656fb6cc7caeb7b4e37068e8a8bf4dc639.zip
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  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/sparc')
-rw-r--r--sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c4
1 files changed, 2 insertions, 2 deletions
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;
 }