HomeFreeBSD

libc: Fix "harmless" iconv one-byte overread

Description

libc: Fix "harmless" iconv one-byte overread

Checking there are still bytes left must be done before dereferencing
the pointer, not the other way round. This is harmless on traditional
architectures since the result will immediately be thrown away, and all
callers are in separate translation units so there is no potential for
optimising based on this out-of-bounds read. However, on CHERI, pointers
are bounded, and so this will trap if fed a string that does not have a
NUL within the first len bytes.

Found by: CHERI
Reviewed by: brooks

Details

Provenance
jrtc27Authored on Dec 21 2021, 10:47 PM
Parents
rGd074adf18be2: cryptodev.h: Drop 'extern' from function prototypes.
Branches
Unknown
Tags
Unknown