diff options
author | Wilco Dijkstra <wilco.dijkstra@arm.com> | 2022-06-10 17:13:29 +0100 |
---|---|---|
committer | Wilco Dijkstra <wdijkstr@arm.com> | 2022-06-10 17:13:29 +0100 |
commit | fdaf78656fb6cc7caeb7b4e37068e8a8bf4dc639 (patch) | |
tree | 05302f7351e2b505af1d50d165bbbe371123d15d /sysdeps/powerpc | |
parent | f107b7b30d815f191181617e2c14f21e6af4ddcf (diff) | |
download | glibc-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/powerpc')
-rw-r--r-- | sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c | 9 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c | 9 |
2 files changed, 4 insertions, 14 deletions
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c index 01890367a4..e6ef5e6267 100644 --- a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c +++ b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c @@ -22,16 +22,11 @@ #include <ldsodefs.h> #include <ifunc-impl-list.h> -/* Maximum number of IFUNC implementations. */ -#define MAX_IFUNC 6 - size_t __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, size_t max) { - assert (max >= MAX_IFUNC); - - size_t i = 0; + size_t i = max; unsigned long int hwcap = GLRO(dl_hwcap); /* hwcap contains only the latest supported ISA, the code checks which is @@ -179,5 +174,5 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_IMPL_ADD (array, i, strchr, 1, __strchr_ppc)) - return i; + return 0; } diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c index ac533a9886..5a3c7a5886 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c +++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c @@ -22,16 +22,11 @@ #include <ldsodefs.h> #include <ifunc-impl-list.h> -/* Maximum number of IFUNC implementations. */ -#define MAX_IFUNC 6 - size_t __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, size_t max) { - assert (max >= MAX_IFUNC); - - size_t i = 0; + size_t i = max; unsigned long int hwcap = GLRO(dl_hwcap); unsigned long int hwcap2 = GLRO(dl_hwcap2); @@ -448,5 +443,5 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_IMPL_ADD (array, i, strcasestr, 1, __strcasestr_ppc)) - return i; + return 0; } |