tools: libinput-record: put extra guard in to protect from OOB access

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2018-06-11 11:20:09 +10:00
parent 8865d4a29d
commit b4ff592a5a

View file

@ -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);