After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 773842 - [PATCH] g_utf8_find_next_char() won't signal the end of a NUL-terminated string
[PATCH] g_utf8_find_next_char() won't signal the end of a NUL-terminated string
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2016-11-02 16:57 UTC by Lubomir Rintel
Modified: 2017-06-21 10:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH] Return NULL when g_utf8_find_next_char() reached terminating nul (1.16 KB, patch)
2016-11-02 16:57 UTC, Lubomir Rintel
rejected Details | Review
gutf8: Clarify return value docs for g_utf8_find_next_char() (1.90 KB, patch)
2017-06-20 12:41 UTC, Philip Withnall
committed Details | Review

Description Lubomir Rintel 2016-11-02 16:57:39 UTC
Created attachment 338964 [details] [review]
[PATCH] Return NULL when g_utf8_find_next_char() reached terminating nul

This use of g_utf8_find_next_char() proceeds beyond the end of the string:

https://git.gnome.org/browse/gnome-control-center/tree/shell/hostname-helper.c?h=gnome-3-22#n198
Comment 1 Lubomir Rintel 2017-06-20 11:02:49 UTC
Ping?
Comment 2 Philip Withnall 2017-06-20 12:25:13 UTC
Review of attachment 338964 [details] [review]:

No, this would be an API break; there are cases in the wild where callers will unconditionally dereference the return value from g_utf8_find_next_char(). Returning NULL will cause them to crash.

For example, see g_key_file_is_group_name() in gkeyfile.c in GLib.

We can improve the documentation to make this clearer, but we can’t change the behaviour of g_utf8_find_next_char().
Comment 3 Philip Withnall 2017-06-20 12:41:54 UTC
Created attachment 354096 [details] [review]
gutf8: Clarify return value docs for g_utf8_find_next_char()

Make it clearer that it will only return NULL if @end is non-NULL. Add a
test for this too.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Comment 4 Emmanuele Bassi (:ebassi) 2017-06-21 10:35:59 UTC
Review of attachment 354096 [details] [review]:

Looks good.
Comment 5 Philip Withnall 2017-06-21 10:40:22 UTC
Attachment 354096 [details] pushed as 1366ce7 - gutf8: Clarify return value docs for g_utf8_find_next_char()