From e3f4e0d71a8ea3b51521abb30dc6868a6b71c81b Mon Sep 17 00:00:00 2001 From: Aaron Oneal Date: Wed, 6 Sep 2017 23:37:46 -0700 Subject: [PATCH] Fix ISO scan crash from buffer overflow Recent additions in commit #bbb2a7d6f to scan ISO files with ASCII characters overflowed the serial number buffer and caused a crash. This fix limits the read to 15 bytes which is all that is actually required. --- tasks/task_database_cue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks/task_database_cue.c b/tasks/task_database_cue.c index 738dc30b13..eb76997f56 100644 --- a/tasks/task_database_cue.c +++ b/tasks/task_database_cue.c @@ -350,7 +350,8 @@ int detect_serial_ascii_game(const char *track_path, char *game_id) for (pos = 0; pos < 10000; pos++) { filestream_seek(fd, pos, SEEK_SET); - if (filestream_read(fd, game_id, 10000) > 0) + /* Current logic only requires 15 characters (max of 4096 per sizeof game_id). */ + if (filestream_read(fd, game_id, 15) > 0) { unsigned i; game_id[15] = '\0';