Strings from the config parser can be of length 0, so we should check that before checking the string's bytes.
The x11 backend's usage is technically safe since the null terminator is present, but I've changed it too in case someone's looking at it as a reference for new code. --- src/compositor-wayland.c | 2 +- src/compositor-x11.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c index bf71a76..e107002 100644 --- a/src/compositor-wayland.c +++ b/src/compositor-wayland.c @@ -2108,7 +2108,7 @@ backend_init(struct wl_display *display, int *argc, char *argv[], if (name == NULL) continue; - if (name[0] != 'W' || name[1] != 'L') { + if (strlen(name) < 2 || name[0] != 'W' || name[1] != 'L') { free(name); continue; } diff --git a/src/compositor-x11.c b/src/compositor-x11.c index 1baee29..ae237c8 100644 --- a/src/compositor-x11.c +++ b/src/compositor-x11.c @@ -1550,7 +1550,7 @@ x11_compositor_create(struct wl_display *display, if (strcmp(section_name, "output") != 0) continue; weston_config_section_get_string(section, "name", &name, NULL); - if (name == NULL || name[0] != 'X') { + if (name == NULL || strlen(name) < 1 || name[0] != 'X') { free(name); continue; } -- 2.1.1 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel