usr.sbin/fstyp: Fix intra-object buffer overread for labeled msdosfs volumes
commitbc425cd926be5780293e34a801f97124ce041690
authorTomohiro Kusumi <tkusumi@netbsd.org>
Wed, 3 Nov 2021 13:35:00 +0000 (3 22:35 +0900)
committerTomohiro Kusumi <tkusumi@netbsd.org>
Wed, 3 Nov 2021 13:35:00 +0000 (3 22:35 +0900)
tree8dab73779db801c7488fd60665de2ba58871902e
parent6a86f56a2ea68a83c081c6c0cb447834e73097cb
usr.sbin/fstyp: Fix intra-object buffer overread for labeled msdosfs volumes

Volume labels, like directory entries, are padded with spaces and so
have no NUL terminator. Whilst the MIN for the dsize argument to strlcpy
ensures that the copy does not overflow the destination, strlcpy is
defined to return the number of characters in the source string,
regardless of the provided dsize, and so keeps reading until it finds a
NUL, which likely exists somewhere within the following fields, but On
CHERI with the subobject bounds enabled in the compiler this buffer
overread will be detected and trap with a bounds violation.

taken from FreeBSD
34fb1c133c5b8616f14f1d740d99747b427f5571
63d24336fd1aad81a4bdefb11d8c487cee5f88a0
usr.sbin/fstyp/msdosfs.c