fortify-headers: wcrtomb causes SIGILL on EILSEQ
The POSIX definition of wcrtomb (http://pubs.opengroup.org/onlinepubs/9699919799/functions/wcrtomb.html) states:
When wc is not a valid wide character, an encoding error shall occur. In this case, the function shall store the value of the macro [EILSEQ] in errno and shall return (size_t)–1; the conversion state shall be undefined.
The fortify-headers implementation of wcrtomb interprets the result –1 as 18446744073709551615 bytes. Since this is the highest 64-bit number possible, it is pretty safe to say this will always be larger than any buffer provided to wcrtomb. Therefore, it traps.
Attached is a patch that fixes this issue. Since I could not find contact information for upstream, and the project originated with Alpine, I figured it was most appropriate to file here.
(from redmine: issue id 7681, created on 2017-08-13, closed on 2019-02-25)
- Revision d4f8e1e2 by Natanael Copa on 2017-08-25T22:36:32Z:
main/fortify-headers: upgrade to 0.9 fixes #7681