]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
ply-utils: Make ply_utf8_character_get_byte_type detect invalid bytes
authorRay Strode <rstrode@redhat.com>
Wed, 3 Jan 2024 14:53:50 +0000 (09:53 -0500)
committerRay Strode <rstrode@redhat.com>
Wed, 3 Jan 2024 16:13:31 +0000 (11:13 -0500)
Somehow I neglected to make ply_utf8_character_get_byte_type
differentiate between valid and invalid utf-8.

This commit fixes that.

src/libply/ply-utils.c

index 95b505b170f6ee40e60c2bbf6cafccd238a8c99f..463f61c927205b5c779c73220323bd71a4258189 100644 (file)
@@ -757,8 +757,10 @@ ply_utf8_character_get_byte_type (const char byte)
                 byte_type = PLY_UTF8_CHARACTER_BYTE_TYPE_3_BYTES;
         else if ((byte & 0xF8) == 0xF0)
                 byte_type = PLY_UTF8_CHARACTER_BYTE_TYPE_4_BYTES;
-        else
+        else if ((byte & 0xC0) == 0x80)
                 byte_type = PLY_UTF8_CHARACTER_BYTE_TYPE_CONTINUATION;
+        else
+                byte_type = PLY_UTF8_CHARACTER_BYTE_TYPE_INVALID;
 
         return byte_type;
 }