opnsense-src/lib/libc/string
John Baldwin deebb011a4 swab: Correctly treat the data as misaligned
The __aligned attribute in the previous version applied to the location
of the pointers, not the data the pointers pointed to.  While this
could be fixed by applying the attribute to a local typedef of uint16_t,
just using memcpy() for the unaligned access is simpler and ISO C.

This fixes the build on CHERI architectures which do not support
misaligned pointers and were thus failing with:

lib/libc/string/swab.c:12:18: error: alignment (1) of 'const uint16_t *' (aka 'const unsigned short *') is less than the required capability alignment (16) [-Werror,-Wcheri-capability-misuse]
   12 |         const uint16_t *f __aligned(1) = from;
      |

Co-authored by:	Jessica Clarke <jrtc27@FreeBSD.org>
Fixes:		02ebbc781f ("swab: Fix implementation to support overlapping copies")
Sponsored by:	AFRL, DARPA

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D54399

(cherry picked from commit 2a5c5b8f7cddf14537707895fceb454cabc1b3bd)
2026-04-24 11:26:38 -04:00
..
bcmp.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
bcmp.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
bcopy.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
bcopy.c Prepare the system for _FORTIFY_SOURCE 2024-05-13 00:23:50 -05:00
bstring.3 manuals: Fix "unusual .Xr" warnings with a script 2024-10-15 17:18:14 -03:00
bzero.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
bzero.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
ffs.3 man/man3: add cross references to stdbit(3) 2026-01-01 21:57:33 +01:00
ffs.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
ffsl.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
ffsll.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
fls.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
flsl.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
flsll.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
index.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
Makefile.inc libc/string: add strdupa(3) and strndupa(3) 2025-12-16 06:57:01 +02:00
memccpy.3 manuals: Align our tree with upstream C23 macro 2025-06-12 17:24:10 -04:00
memccpy.c lib/libc/string: document restrict qualification of memccpy() arguments 2023-12-25 14:59:50 +01:00
memchr.3 memchr.3: Operates on objects, not strings 2025-07-25 09:48:42 -04:00
memchr.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
memcmp.3 memcmp.3: Clarify return value 2024-11-20 12:15:11 -05:00
memcmp.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
memcpy.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
memcpy.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
memmem.3 libc: indicate existing functions that are POSIX 2024 2024-11-14 21:32:20 -05:00
memmem.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
memmove.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
memmove.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
mempcpy.c include: ssp: don't shadow the mempcpy builtin 2024-07-16 00:12:28 -05:00
memrchr.c Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
memset.3 manuals: Align our tree with upstream C23 macro 2025-06-12 17:24:10 -04:00
memset.c Prepare the system for _FORTIFY_SOURCE 2024-05-13 00:23:50 -05:00
memset_explicit.c lib/libc/string: apply SSP hardening and tests to memset_explicit 2024-11-14 23:10:00 +01:00
memset_s.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
stpcpy.c Prepare the system for _FORTIFY_SOURCE 2024-05-13 00:23:50 -05:00
stpncpy.c Prepare the system for _FORTIFY_SOURCE 2024-05-13 00:23:50 -05:00
strcasecmp.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strcasecmp.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strcasestr.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strcat.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strcat.c Prepare the system for _FORTIFY_SOURCE 2024-05-13 00:23:50 -05:00
strchr.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strchr.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strchrnul.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strcmp.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strcmp.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strcoll.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strcoll.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strcpy.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strcpy.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strcspn.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strdup.3 libc/string: add strdupa(3) and strndupa(3) 2025-12-16 06:57:01 +02:00
strdup.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strerror.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strerror.c include: ssp: round out fortification of current set of headers 2024-07-13 00:16:24 -05:00
string.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strlcat.c include: ssp: round out fortification of current set of headers 2024-07-13 00:16:24 -05:00
strlcpy.3 strlcpy/strlcat: Remove references to snprintf 2023-10-27 10:13:50 -06:00
strlcpy.c include: ssp: round out fortification of current set of headers 2024-07-13 00:16:24 -05:00
strlen.3 strnlen(3): add HISTORY 2024-03-15 14:52:47 -07:00
strlen.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strmode.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strmode.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strncat.c Prepare the system for _FORTIFY_SOURCE 2024-05-13 00:23:50 -05:00
strncmp.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strncpy.c include: ssp: round out fortification of current set of headers 2024-07-13 00:16:24 -05:00
strndup.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strnlen.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strnstr.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strpbrk.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strpbrk.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strrchr.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strsep.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strsep.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strsignal.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strspn.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strspn.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strstr.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strstr.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
strtok.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strtok.c lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strverscmp.3 libc: fix history for strverscmp(3) and versionsort(3) 2023-08-31 14:52:31 +03:00
strverscmp.c libc: Add strverscmp(3) and versionsort(3) 2022-08-25 03:29:03 +03:00
strxfrm.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
strxfrm.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
swab.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
swab.c swab: Correctly treat the data as misaligned 2026-04-24 11:26:38 -04:00
Symbol.map lib/libc/string: add memset_explicit() for compliance with C23 2024-11-14 23:10:00 +01:00
timingsafe_bcmp.3 timingsafe_bcmp(3) was MFC'ed to 11.1 2024-01-05 20:54:13 -08:00
timingsafe_bcmp.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
timingsafe_memcmp.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcpcpy.c include: ssp: fortify <wchar.h> 2024-07-13 00:16:25 -05:00
wcpncpy.c include: ssp: fortify <wchar.h> 2024-07-13 00:16:25 -05:00
wcscasecmp.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcscat.c include: ssp: fortify <wchar.h> 2024-07-13 00:16:25 -05:00
wcschr.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcscmp.c sccs: Manual changes 2023-11-26 22:23:58 -07:00
wcscoll.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
wcscoll.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcscpy.c include: ssp: fortify <wchar.h> 2024-07-13 00:16:25 -05:00
wcscspn.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wcsdup.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcslcat.c include: ssp: fortify <wchar.h> 2024-07-13 00:16:25 -05:00
wcslcpy.c include: ssp: fortify <wchar.h> 2024-07-13 00:16:25 -05:00
wcslen.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wcsncasecmp.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcsncat.c include: ssp: fortify <wchar.h> 2024-07-13 00:16:25 -05:00
wcsncmp.c sccs: Manual changes 2023-11-26 22:23:58 -07:00
wcsncpy.c include: ssp: fortify <wchar.h> 2024-07-13 00:16:25 -05:00
wcsnlen.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcspbrk.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wcsrchr.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcsspn.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wcsstr.c lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
wcstok.3 Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
wcstok.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcswidth.3 Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
wcswidth.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wcsxfrm.3 lib: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
wcsxfrm.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
wmemchr.3 wmemchr(3): fix prototypes for wcpcpy() and wcpncpy() 2024-03-21 10:40:08 +02:00
wmemchr.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wmemcmp.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
wmemcpy.c include: ssp: fortify <wchar.h> 2024-07-13 00:16:25 -05:00
wmemmove.c include: ssp: fortify <wchar.h> 2024-07-13 00:16:25 -05:00
wmempcpy.c include: ssp: fortify <wchar.h> 2024-07-13 00:16:25 -05:00
wmemset.c include: ssp: fortify <wchar.h> 2024-07-13 00:16:25 -05:00