Overview
Comment: | Correctly check the length in of_string_check_utf8. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | 0.5 |
Files: | files | file ages | folders |
SHA3-256: |
1c2f416cb96ccbb72cdbfb74a0f01764 |
User & Date: | js on 2011-05-14 23:26:00 |
Other Links: | branch diff | manifest | tags |
Context
2011-05-15
| ||
00:32 | configure.ac: Fix two tests that would fail with Clang + new ABI. check-in: 76ab337747 user: js tags: 0.5 | |
2011-05-14
| ||
23:26 | Correctly check the length in of_string_check_utf8. check-in: 1c2f416cb9 user: js tags: 0.5 | |
20:00 | Fix namespace handling in OFXMLElement. check-in: 21bd46e17a user: js tags: 0.5 | |
Changes
Modified src/OFString.m from [ada3b84c8f] to [dd37a07a33].
︙ | ︙ | |||
95 96 97 98 99 100 101 | /* We're missing a start byte here */ if (OF_UNLIKELY(!(str[i] & 0x40))) { madvise((void*)str, len, MADV_NORMAL); return -1; } /* We have at minimum a 2 byte character -> check next byte */ | | | | | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | /* We're missing a start byte here */ if (OF_UNLIKELY(!(str[i] & 0x40))) { madvise((void*)str, len, MADV_NORMAL); return -1; } /* We have at minimum a 2 byte character -> check next byte */ if (OF_UNLIKELY(len <= i + 1 || (str[i + 1] & 0xC0) != 0x80)) { madvise((void*)str, len, MADV_NORMAL); return -1; } /* Check if we have at minimum a 3 byte character */ if (OF_LIKELY(!(str[i] & 0x20))) { i++; continue; } /* We have at minimum a 3 byte char -> check second next byte */ if (OF_UNLIKELY(len <= i + 2 || (str[i + 2] & 0xC0) != 0x80)) { madvise((void*)str, len, MADV_NORMAL); return -1; } /* Check if we have a 4 byte character */ if (OF_LIKELY(!(str[i] & 0x10))) { i += 2; continue; } /* We have a 4 byte character -> check third next byte */ if (OF_UNLIKELY(len <= i + 3 || (str[i + 3] & 0xC0) != 0x80)) { madvise((void*)str, len, MADV_NORMAL); return -1; } /* * Just in case, check if there's a 5th character, which is * forbidden by UTF-8 |
︙ | ︙ |