]> git.ipfire.org Git - thirdparty/glibc.git/commit
Fix powerpc64/power7 memchr for large input sizes
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 15 Dec 2016 18:27:10 +0000 (18:27 +0000)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 16 Dec 2016 13:30:20 +0000 (11:30 -0200)
commitb224637928e9fc04e3cef3e10d02ccf042d01584
tree5039ee55ad35414936bff34c31c5b3bd05a31e3a
parente4d6a83565479c533aabae9046377a59712a5b22
Fix powerpc64/power7 memchr for large input sizes

Current optimized powercp64/power7 memchr uses a strategy to check for
p versus align(p+n) (where 'p' is the input char pointer and n the
maximum size to check for the byte) without taking care for possible
overflow on the pointer addition in case of large 'n'.

It was triggered by 3038145ca23 where default rawmemchr (used to
created ppc64 rawmemchr in ifunc selection) now uses memchr (p, c, (size_t)-1)
on its implementation.

This patch fixes it by implement a satured addition where overflows
sets the maximum pointer size to UINTPTR_MAX.

Checked on powerpc64le-linux-gnu.

[BZ# 20971]
* sysdeps/powerpc/powerpc64/power7/memchr.S (__memchr): Avoid
overflow in pointer addition.
* string/test-memchr.c (do_test): Add an argument to pass as
the size on memchr.
(test_main): Add check for SIZE_MAX.
ChangeLog
string/test-memchr.c
sysdeps/powerpc/powerpc64/power7/memchr.S