forked from GNOME/glib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gutf8: Drop ifunc code and always call strlen() when validating UTF-8
This fixes a heap buffer overflow read in `g_utf8_validate()` and `g_str_is_ascii()`, at the cost of always calling `strlen()` on the input string if its length isn’t known already. The overflow read was not a security vulnerability, but getting valgrind and asan to understand that, across all platforms and build configurations, doesn’t seem to be possible with the resources available to us. In particular, the `ifunc` approach doesn’t work on muslc, and doesn’t work when statically linked. The UTF-8 validation code should still be faster than the old approach (GLib 2.82 and older), as `strlen()` is SIMD-accelerated in glibc, and UTF-8 validation is SIMD accelerated in GLib. The combination of the two should still be faster than the bytewise read loop we used to have. Unfortunately, correctness and testability have to be prioritised over absolute performance. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Fixes: #3493 Fixes: #3511 Fixes: #3526
- Loading branch information
Showing
1 changed file
with
8 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters