RFR: 8325002: Exceptions::fthrow needs to ensure it truncates to a valid utf8 string

Daniel Jeliński djelinski at openjdk.org
Sat Jul 27 07:28:37 UTC 2024


On Fri, 26 Jul 2024 21:43:49 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> src/hotspot/share/utilities/utf8.cpp line 442:
>> 
>>> 440:         if ((index - 3) >= 0 && ((buffer[index - 2] & 0xA0) == 0xA0)) {
>>> 441:           // it was fourth byte so truncate 3 bytes earlier
>>> 442:           assert(buffer[index - 3] == 0xED, "malformed sequence");
>> 
>> This needs to be an if, not an assert: ec-a0-80 is a [legitimate 3-byte UTF-8](https://www.compart.com/en/unicode/U+C800)
>
> Will need to re-examine this part.

Keep in mind that 0xed a few lines above could have matched the first byte and not the fourth one.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20345#discussion_r1693913232


More information about the hotspot-dev mailing list