summaryrefslogtreecommitdiff
path: root/tools/libinput-record.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2018-06-11 11:20:09 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2018-06-11 13:43:40 +1000
commitb4ff592a5ab6ebdc9c993fa78f1194313485d580 (patch)
tree2df5a8af01947531478cf13a23ec78f47174aea6 /tools/libinput-record.c
parent8865d4a29dfb2d50ec08d464a120069bad633f26 (diff)
tools: libinput-record: put extra guard in to protect from OOB access
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools/libinput-record.c')
-rw-r--r--tools/libinput-record.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/libinput-record.c b/tools/libinput-record.c
index 18b653c5..71d4fe11 100644
--- a/tools/libinput-record.c
+++ b/tools/libinput-record.c
@@ -716,6 +716,7 @@ buffer_gesture_event(struct record_context *ctx,
static char *
buffer_tablet_axes(struct libinput_event_tablet_tool *t)
{
+ const int MAX_AXES = 10;
struct libinput_tablet_tool *tool;
char *s = NULL;
int idx = 0;
@@ -725,7 +726,7 @@ buffer_tablet_axes(struct libinput_event_tablet_tool *t)
tool = libinput_event_tablet_tool_get_tool(t);
- strv = zalloc(10 * sizeof *strv);
+ strv = zalloc(MAX_AXES * sizeof *strv);
x = libinput_event_tablet_tool_get_x(t);
y = libinput_event_tablet_tool_get_y(t);
@@ -789,6 +790,8 @@ buffer_tablet_axes(struct libinput_event_tablet_tool *t)
goto out;
}
+ assert(idx < MAX_AXES);
+
s = strv_join(strv, ", ");
out:
strv_free(strv);