hostname-helper: don't read past '\0'

g_utf8_find_next_char() doesn't do checks whether the char
is '\0' or not. We have to take care of that ourself.

This commit fixes heap-buffer-overflow found by test-hostname

ERROR: AddressSanitizer: heap-buffer-overflow on address
READ of size 1 at 0x60200000cd76 thread T0
 #0 0x7f8b26920d08 in g_utf8_find_next_char glib/glib/gutf8.c:179
 #1 0x55c2b8eacaee in pretty_hostname_to_ssid gnome-control-center/shell/hostname-helper.c:199

https://bugzilla.gnome.org/show_bug.cgi?id=782216
This commit is contained in:
Mohammed Sadiq 2017-05-05 17:40:33 +05:30 committed by Bastien Nocera
parent da43d79022
commit d153b9b4ee

View file

@ -208,6 +208,9 @@ pretty_hostname_to_ssid (const char *pretty)
break;
}
if (*p == '\0')
break;
prev = p;
}