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 /include | |
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 'include')
-rw-r--r-- | include/ifunc-impl-list.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/include/ifunc-impl-list.h b/include/ifunc-impl-list.h index 78087f015c..00bf48f3f1 100644 --- a/include/ifunc-impl-list.h +++ b/include/ifunc-impl-list.h @@ -34,15 +34,15 @@ struct libc_ifunc_impl /* Add an IFUNC implementation, IMPL, for function FUNC, to ARRAY with USABLE at index I and advance I by one. */ -#define IFUNC_IMPL_ADD(array, i, func, usable, impl) \ +#define IFUNC_IMPL_ADD(array, max, func, usable, impl) \ extern __typeof (func) impl attribute_hidden; \ - (array)[i++] = (struct libc_ifunc_impl) { #impl, (void (*) (void)) impl, (usable) }; + if (n < max) (array)[n++] = (struct libc_ifunc_impl) { #impl, (void (*) (void)) impl, (usable) }; /* Return the number of IFUNC implementations, N, for function FUNC if string NAME matches FUNC. */ -#define IFUNC_IMPL(n, name, func, ...) \ +#define IFUNC_IMPL(max, name, func, ...) \ if (strcmp (name, #func) == 0) \ - { \ + { size_t n = 0;\ __VA_ARGS__; \ return n; \ } |