1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-06 02:41:11 +01:00

revent: fix off-by-one in replay

Update idx and ev to the next event after the while check (which makes
sure that the next index is within bounds) to avoid a potential
access-past-end-of-array.
This commit is contained in:
Sergei Trofimov 2017-08-02 17:44:46 +01:00
parent 220e0962e1
commit 596595698d
3 changed files with 2 additions and 2 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1265,14 +1265,14 @@ void replay(const char *filepath)
int32_t idx = (recording.events[i]).dev_idx;
struct input_event ev = (recording.events[i]).event;
while((i < recording.num_events) && !timercmp(&ev.time, &last_event_delta, !=)) {
idx = recording.events[i].dev_idx;
ev = recording.events[i].event;
ret = write(recording.devices.fds[idx], &ev, sizeof(ev));
if (ret != sizeof(ev))
die("Could not replay event");
dprintf("replayed event: type %d code %d value %d\n", ev.type, ev.code, ev.value);
i++;
idx = recording.events[i].dev_idx;
ev = recording.events[i].event;
}
last_event_delta = ev.time;
}