]> git.ipfire.org Git - thirdparty/glibc.git/commit
String: Add overflow tests for strnlen, memchr, and strncat [BZ #27974]
authorNoah Goldstein <goldstein.w.n@gmail.com>
Wed, 9 Jun 2021 20:17:14 +0000 (16:17 -0400)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 28 Jan 2022 00:01:04 +0000 (16:01 -0800)
commita3dd272e9c048581c32537cb1390d3efbbc2c3a2
treeb2831ad5b1b7269b9c6e9e93992d5f6c5ac5b6f9
parentae86a6bd4825d24cf4a79e6eb040c4507146649d
String: Add overflow tests for strnlen, memchr, and strncat [BZ #27974]

This commit adds tests for a bug in the wide char variant of the
functions where the implementation may assume that maxlen for wcsnlen
or n for wmemchr/strncat will not overflow when multiplied by
sizeof(wchar_t).

These tests show the following implementations failing on x86_64:

wcsnlen-sse4_1
wcsnlen-avx2

wmemchr-sse2
wmemchr-avx2

strncat would fail as well if it where on a system that prefered
either of the wcsnlen implementations that failed as it relies on
wcsnlen.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit da5a6fba0febbfc90896ce1b2eb75c6d8a88a72d)
string/test-memchr.c
string/test-strncat.c
string/test-strnlen.c