Similiar to [BZ 27974](https://sourceware.org/bugzilla/show_bug.cgi?id=27974). The multiply of length by sizeof (wchar_t) can overflow if length is >= 2^62 which can lead to incorrect results. For example: #include <wchar.h> int main(int argc, char ** argv) { assert(__wcsncmp_evex(L"abc", L"abd", (1UL << 62)) != 0); assert(__wcsncmp_avx2(L"abc", L"abd", (1UL << 62)) != 0); } Will fail on either assert.
Fix proposed in the following patches: avx2: https://patchwork.sourceware.org/project/glibc/patch/20220110002746.3653516-1-goldstein.w.n@gmail.com/ evex: https://patchwork.sourceware.org/project/glibc/patch/20220110002746.3653516-2-goldstein.w.n@gmail.com/
Fixed in commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87 Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:21 2022 -0600 x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] and commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:28 2022 -0600 x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755]
The release/2.34/master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=72123e1b56f53f9205bb105f8a62d0869b837b22 commit 72123e1b56f53f9205bb105f8a62d0869b837b22 Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Jan 26 20:20:43 2022 -0800 NEWS: Add a bug entry for BZ #28755
The release/2.33/master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=86c153d0922a6da3263f0ade42573bd405d8edee commit 86c153d0922a6da3263f0ade42573bd405d8edee Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Jan 26 20:28:51 2022 -0800 NEWS: Add a bug fix entry for BZ #28755
The release/2.32/master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=40eebb02ccbc2d621e796795d5994fe7483b679f commit 40eebb02ccbc2d621e796795d5994fe7483b679f Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Jan 26 21:00:25 2022 -0800 NEWS: Add a bug fix entry for BZ #28755
The release/2.31/master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5b136510856f3742b58eb5e2de0cada7e9e95630 commit 5b136510856f3742b58eb5e2de0cada7e9e95630 Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Jan 27 05:16:30 2022 -0800 NEWS: Add a bug fix entry for BZ #28755
The release/2.30/master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9d868841f870c22c05e5ce11900afc9abd8fda02 commit 9d868841f870c22c05e5ce11900afc9abd8fda02 Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Jan 27 05:31:02 2022 -0800 NEWS: Add a bug fix entry for BZ #28755
The release/2.29/master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2f3fb944b311b67e609ed79478cc1737f6066af9 commit 2f3fb944b311b67e609ed79478cc1737f6066af9 Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Jan 27 05:34:02 2022 -0800 NEWS: Add a bug fix entry for BZ #28755
The release/2.28/master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=43c27a754bd417726032006d0a564d946994554e commit 43c27a754bd417726032006d0a564d946994554e Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Jan 27 07:30:10 2022 -0800 NEWS: Add a bug fix entry for BZ #28755
Fixed for 2.35 and all release branches.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=aa5a720056d37cf24924c138a3dbe6dace98e97c commit aa5a720056d37cf24924c138a3dbe6dace98e97c Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Feb 17 08:10:35 2022 -0800 string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755] Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0. The new test fails without commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87 Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:21 2022 -0600 x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] and commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:28 2022 -0600 x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755] This is for BZ #28755. Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
The release/2.35/master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a30807b7db924d31681e9c6e98e78f2f46a2640c commit a30807b7db924d31681e9c6e98e78f2f46a2640c Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Feb 17 08:10:35 2022 -0800 string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755] Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0. The new test fails without commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87 Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:21 2022 -0600 x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] and commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:28 2022 -0600 x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755] This is for BZ #28755. Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com> (cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)
The release/2.34/master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=04d60ce0f21ffe2a4add148cb37a1942dbad64e2 commit 04d60ce0f21ffe2a4add148cb37a1942dbad64e2 Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Feb 17 08:10:35 2022 -0800 string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755] Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0. The new test fails without commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87 Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:21 2022 -0600 x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] and commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:28 2022 -0600 x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755] This is for BZ #28755. Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com> (cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)
The release/2.33/master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=cb922428dc7c5260ea84de482ffe05d2ea766199 commit cb922428dc7c5260ea84de482ffe05d2ea766199 Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Feb 17 08:10:35 2022 -0800 string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755] Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0. The new test fails without commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87 Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:21 2022 -0600 x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] and commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:28 2022 -0600 x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755] This is for BZ #28755. Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com> (cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)
The release/2.32/master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0f8a2390000c4e9a152b5f6cf8220f2560c01e74 commit 0f8a2390000c4e9a152b5f6cf8220f2560c01e74 Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Feb 17 08:10:35 2022 -0800 string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755] Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0. The new test fails without commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87 Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:21 2022 -0600 x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] and commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:28 2022 -0600 x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755] This is for BZ #28755. Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com> (cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)
The release/2.31/master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=775c05b28c1883c5860f582cca68abf9036d9ace commit 775c05b28c1883c5860f582cca68abf9036d9ace Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Feb 17 08:10:35 2022 -0800 string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755] Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0. The new test fails without commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87 Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:21 2022 -0600 x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] and commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:28 2022 -0600 x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755] This is for BZ #28755. Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com> (cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)
The release/2.30/master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=70522b1c1d1ffa5e3bd55aa3c064ea93a330bde9 commit 70522b1c1d1ffa5e3bd55aa3c064ea93a330bde9 Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Feb 17 08:10:35 2022 -0800 string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755] Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0. The new test fails without commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87 Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:21 2022 -0600 x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] and commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:28 2022 -0600 x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755] This is for BZ #28755. Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com> (cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)
The release/2.29/master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a486152569be7ccdd748f669631285e1a16f2e73 commit a486152569be7ccdd748f669631285e1a16f2e73 Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Feb 17 08:10:35 2022 -0800 string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755] Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0. The new test fails without commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87 Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:21 2022 -0600 x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] and commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:28 2022 -0600 x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755] This is for BZ #28755. Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com> (cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)
The release/2.28/master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9e050d1370587e808bc7bc3d151c5beb417120cb commit 9e050d1370587e808bc7bc3d151c5beb417120cb Author: H.J. Lu <hjl.tools@gmail.com> Date: Thu Feb 17 08:10:35 2022 -0800 string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755] Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0. The new test fails without commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87 Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:21 2022 -0600 x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] and commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b Author: Noah Goldstein <goldstein.w.n@gmail.com> Date: Sun Jan 9 16:02:28 2022 -0600 x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755] This is for BZ #28755. Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com> (cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)