[PATCH weston] backends: don't run off the end of strings
Derek Foreman
derekf at osg.samsung.com
Thu Oct 23 10:21:53 PDT 2014
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
More information about the wayland-devel
mailing list