]> git.ipfire.org Git - thirdparty/glibc.git/commit
s390x: Fix segfault in wcsncmp [BZ #31934]
authorStefan Liebler <stli@linux.ibm.com>
Thu, 11 Jul 2024 09:28:53 +0000 (11:28 +0200)
committerStefan Liebler <stli@linux.ibm.com>
Tue, 16 Jul 2024 08:30:45 +0000 (10:30 +0200)
commita70c55a91b2b361f43e4142aadf86f22af57d406
tree0bc135c3924542bea925d19a92938c260568e5e8
parentee65bc1df6268c561e6c62dcc4435fbbf705bc67
s390x: Fix segfault in wcsncmp [BZ #31934]

The z13/vector-optimized wcsncmp implementation segfaults if n=1
and there is only one character (equal on both strings) before
the page end.  Then it loads and compares one character and misses
to check n again.  The following load fails.

This patch removes the extra load and compare of the first character
and just start with the loop which uses vector-load-to-block-boundary.
This code-path also checks n.

With this patch both tests are passing:
- the simplified one mentioned in the bugzilla 31934
- the full one in Florian Weimer's patch:
"manual: Document a GNU extension for strncmp/wcsncmp"
(https://patchwork.sourceware.org/project/glibc/patch/874j9eml6y.fsf@oldenburg.str.redhat.com/):
On s390x-linux-gnu (z16), the new wcsncmp test fails due to bug 31934.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 9b7651410375ec8848a1944992d663d514db4ba7)
sysdeps/s390/wcsncmp-vx.S