mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-10-31 07:04:17 +00: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:
		
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										4
									
								
								wlauto/external/revent/revent.c
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								wlauto/external/revent/revent.c
									
									
									
									
										vendored
									
									
								
							| @@ -1265,14 +1265,14 @@ void replay(const char *filepath) | |||||||
| 		int32_t idx = (recording.events[i]).dev_idx; | 		int32_t idx = (recording.events[i]).dev_idx; | ||||||
| 		struct input_event ev = (recording.events[i]).event; | 		struct input_event ev = (recording.events[i]).event; | ||||||
| 		while((i < recording.num_events) && !timercmp(&ev.time, &last_event_delta, !=)) { | 		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)); | 			ret = write(recording.devices.fds[idx], &ev, sizeof(ev)); | ||||||
| 			if (ret != sizeof(ev)) | 			if (ret != sizeof(ev)) | ||||||
| 				die("Could not replay event"); | 				die("Could not replay event"); | ||||||
| 			dprintf("replayed event: type %d code %d value %d\n", ev.type, ev.code, ev.value); | 			dprintf("replayed event: type %d code %d value %d\n", ev.type, ev.code, ev.value); | ||||||
|  |  | ||||||
| 			i++; | 			i++; | ||||||
| 			idx = recording.events[i].dev_idx; |  | ||||||
| 			ev = recording.events[i].event; |  | ||||||
| 		} | 		} | ||||||
| 		last_event_delta = ev.time; | 		last_event_delta = ev.time; | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user