possible deadlock on invalid UTF-8 data
- From: Daniel Elstner <daniel elstner gmx net>
- To: gtk-devel-list <gtk-devel-list gnome org>
- Subject: possible deadlock on invalid UTF-8 data
- Date: 27 Nov 2001 18:52:47 +0100
Hi,
the utf8_skip_data[] array (glib/gutf8.c:104) contains 0 at index 0xfe
and 0xff. This could easily cause endless loops when iterating over a
UTF-8 string by using g_utf8_next_char().
I know that 0xfe and 0xff are forbidden in UTF-8 strings, but those
shouldn't cause a deadlock IMHO. Sometimes it's just not appropriate to
validate every string before passing it to the g_utf8_* functions.
If you agree on that, I'd be happy to commit this change:
--- glib/gutf8.c 2001/09/27 02:49:05 1.28
+++ glib/gutf8.c 2001/11/27 17:38:58
@@ -104,17 +104,17 @@
static const gchar utf8_skip_data[256] = {
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,0,0
+ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
};
const gchar * const g_utf8_skip = utf8_skip_data;
/**
* g_utf8_find_prev_char:
* @str: pointer to the beginning of a UTF-8 encoded string
* @p: pointer to some position within @str
Cheers,
--Daniel
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]