sheredom / utf8.h

📚 single header utf8 string functions for C and C++
The Unlicense
1.69k stars 123 forks source link

utf8makevalid read out of bounds (+ other functions) #117

Open JPDelprat opened 7 months ago

JPDelprat commented 7 months ago

Hello, It seems to me that utf8makevalid can read string to modify out of bounds :

while ('\0' != read) { if (0xf0 == (0xf8 & read)) { /* ensure each of the 3 following bytes in this 4-byte

=> it seems to me that we cannot be sure that read[1], [2] and [3] are not of bounds.

Regards,

PS : same problem in utf8codepoint and maybe other functions, but this is particularly important for utf8makevalid , because I can have any invaldi string as an input

sheredom commented 7 months ago

Good spot! Would happily accept a PR with testing.