freebsd-dev/lib/libc/string
Ed Maste 33482dae89 libc: fix undefined behavior from signed overflow in strstr and memmem
unsigned char promotes to int, which can overflow when shifted left by
24 bits or more. this has been reported multiple times but then
forgotten. it's expected to be benign UB, but can trap when built with
explicit overflow catching (ubsan or similar). fix it now.

note that promotion to uint32_t is safe and portable even outside of
the assumptions usually made in musl, since either uint32_t has rank
at least unsigned int, so that no further default promotions happen,
or int is wide enough that the shift can't overflow. this is a
desirable property to have in case someone wants to reuse the code
elsewhere.

musl commit: 593caa456309714402ca4cb77c3770f4c24da9da

Obtained from:	musl
2020-11-19 00:03:15 +00:00
..
bcmp.3
bcmp.c
bcopy.3
bcopy.c
bstring.3
bzero.3
bzero.c
ffs.3
ffs.c
ffsl.c
ffsll.c
fls.c
flsl.c
flsll.c
index.3
Makefile.inc
memccpy.3
memccpy.c
memchr.3
memchr.c clang-format libc string functions imported from musl 2020-11-18 22:01:34 +00:00
memcmp.3
memcmp.c
memcpy.3
memcpy.c
memmem.3
memmem.c libc: fix undefined behavior from signed overflow in strstr and memmem 2020-11-19 00:03:15 +00:00
memmove.3
memmove.c
memrchr.c
memset_s.c
memset.3 memset.3: better fix previous typo 2020-02-08 21:17:48 +00:00
memset.c
stpcpy.c
stpncpy.c
strcasecmp.3
strcasecmp.c
strcasestr.c
strcat.3
strcat.c
strchr.3
strchr.c
strchrnul.c
strcmp.3
strcmp.c
strcoll.3
strcoll.c
strcpy.3
strcpy.c [PPC64] strcpy optimization 2020-01-15 19:46:01 +00:00
strcspn.c
strdup.3 strdup.3: Slightly canonicalize OOM return/error status 2020-05-05 17:57:04 +00:00
strdup.c
strerror.3
strerror.c
string.3
strlcat.c
strlcpy.3 libc manpages: various improvements from NetBSD 2020-06-14 05:59:30 +00:00
strlcpy.c
strlen.3
strlen.c
strmode.3
strmode.c
strncat.c
strncmp.c
strncpy.c [PPC64] strncpy optimization 2020-01-15 19:53:03 +00:00
strndup.c
strnlen.c
strnstr.c
strpbrk.3
strpbrk.c
strrchr.c
strsep.3
strsep.c
strsignal.c
strspn.3
strspn.c
strstr.3
strstr.c libc: fix undefined behavior from signed overflow in strstr and memmem 2020-11-19 00:03:15 +00:00
strtok.3 strtok(3): make it easier to find the RETURN VALUES section 2020-06-22 11:03:36 +00:00
strtok.c
strxfrm.3
strxfrm.c
swab.3
swab.c
Symbol.map
timingsafe_bcmp.3
timingsafe_bcmp.c
timingsafe_memcmp.c
wcpcpy.c
wcpncpy.c
wcscasecmp.c
wcscat.c
wcschr.c
wcscmp.c
wcscoll.3
wcscoll.c
wcscpy.c
wcscspn.c
wcsdup.c
wcslcat.c
wcslcpy.c
wcslen.c
wcsncasecmp.c
wcsncat.c
wcsncmp.c
wcsncpy.c
wcsnlen.c
wcspbrk.c
wcsrchr.c
wcsspn.c
wcsstr.c
wcstok.3
wcstok.c
wcswidth.3
wcswidth.c
wcsxfrm.3
wcsxfrm.c
wmemchr.3
wmemchr.c
wmemcmp.c
wmemcpy.c
wmemmove.c
wmemset.c