[PATCH 2/2] Ensure strncpy results are null terminated.

Bryce Harrington bryce at osg.samsung.com
Fri Aug 28 13:04:27 PDT 2015


Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
---
 clients/window.c       | 1 +
 src/compositor-fbdev.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/clients/window.c b/clients/window.c
index 0e73f5b..614b320 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -5886,6 +5886,7 @@ keysym_modifiers_add(struct wl_array *modifiers_map,
 		return;
 
 	strncpy(p, name, len);
+	p[len-1] = '\0';
 }
 
 static xkb_mod_index_t
diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
index a5c7947..b90975c 100644
--- a/src/compositor-fbdev.c
+++ b/src/compositor-fbdev.c
@@ -338,6 +338,7 @@ fbdev_query_screen_info(struct fbdev_output *output, int fd,
 	info->buffer_length = fixinfo.smem_len;
 	info->line_length = fixinfo.line_length;
 	strncpy(info->id, fixinfo.id, sizeof(info->id) / sizeof(*info->id));
+	info->id[sizeof(info->id)-1] = '\0';
 
 	info->pixel_format = calculate_pixman_format(&varinfo, &fixinfo);
 	info->refresh_rate = calculate_refresh_rate(&varinfo);
-- 
1.9.1



More information about the wayland-devel mailing list