]> 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)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Wed, 23 Jun 2021 18:13:00 +0000 (14:13 -0400)
commitda5a6fba0febbfc90896ce1b2eb75c6d8a88a72d
treeb0b24fa0d148725804d45f3204c985243d38d526
parent6f573a27b6c8b4236445810a44660612323f5a73
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>
string/test-memchr.c
string/test-strncat.c
string/test-strnlen.c