usr.bin/sort: Avoid UBSan errors
authorAlex Richardson <arichardson@FreeBSD.org>
Mon, 5 Jul 2021 13:32:48 +0000 (14:32 +0100)
committerAlex Richardson <arichardson@FreeBSD.org>
Tue, 6 Jul 2021 09:51:05 +0000 (10:51 +0100)
commitd053fb22f6d3b6bb0f4e47e4507fefc20cbe0e32
treed2d4317f9aa1ed997819717835a9e58a5627337a
parenta081a943a0ece20cf4ed28681ec3e01baa94ca2e
usr.bin/sort: Avoid UBSan errors

UBSan complains about out-of-bounds accesses for zero-length arrays. To
avoid this we can use flexible array members. However, the C standard does
not allow for structures that only contain flexible array members, so we
move the length parameters into that structure too.

Split out from D28233.

Reviewed By: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31009
usr.bin/sort/Makefile
usr.bin/sort/bwstring.c
usr.bin/sort/bwstring.h