freebsd-src/sys/libkern
Mark Johnston 73586fcea6 libkern: Avoid a one-byte OOB access in strndup()
If the length of the string is maxlen, we would end up copying maxlen+1
bytes, which violates the contract of the function.  The result is the
same since that extra byte is overwritten.

Reported by:	Kevin Day <kevin@your.org>
Reviewed by:	imp, kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D54093
2025-12-08 14:08:22 +00:00
..
arm sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
arm64 Fix possible out of bounds read in armv8_crc32c 2025-09-10 10:21:38 -04:00
x86 libkern: Use proper prototype for SYSINIT functions 2025-10-13 18:12:31 +08:00
arc4random.c libkern: Use proper prototype for SYSINIT functions 2025-10-13 18:12:31 +08:00
arc4random_uniform.c
ashldi3.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
ashrdi3.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
asprintf.c machine/stdarg.h -> sys/stdarg.h 2025-06-11 17:39:02 +01:00
bcd.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
bcopy.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
bsearch.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
cmpdi2.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
crc16.c
divdi3.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
divmoddi4.c
explicit_bzero.c include: ssp: round out fortification of current set of headers 2024-07-13 00:16:24 -05:00
fnmatch.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
gsb_crc32.c gsb_crc32.c: avoid gcc -Wunused-const-variable in user build 2024-07-02 12:12:22 -07:00
iconv.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
iconv_converter_if.m sys: Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:54:58 -06:00
iconv_ucs.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
iconv_xlat.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
iconv_xlat16.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
inet_aton.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
inet_ntoa.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
inet_ntop.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
inet_pton.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
jenkins_hash.c sys: Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:18 -06:00
lshrdi3.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
memcchr.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
memchr.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
memcmp.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
memmem.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
memset.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
moddi3.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
murmur3_32.c
qdivrem.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
qsort.c libkern: Drop incorrect qsort optimization 2025-08-16 01:23:35 +02:00
qsort_r.c
quad.h sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
random.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
scanc.c sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
strcasecmp.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
strcasestr.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
strcat.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
strchr.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
strchrnul.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
strcmp.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
strcpy.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
strcspn.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
strdup.c libkern: strdup.c, strndup.c: Prefer memcpy() over bcopy() 2025-02-17 23:37:59 +08:00
strlcat.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
strlcpy.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
strlen.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
strncat.c sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
strncmp.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
strncpy.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
strndup.c libkern: Avoid a one-byte OOB access in strndup() 2025-12-08 14:08:22 +00:00
strnlen.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
strnstr.c
strrchr.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
strsep.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
strspn.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
strstr.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
strtol.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
strtoq.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
strtoul.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
strtouq.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
strvalid.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
timingsafe_bcmp.c
ucmpdi2.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
udivdi3.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
udivmoddi4.c
umoddi3.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00