Correctly signal errors for out-of-bounds async CD reads
authorJustin Weiss <justin@justinweiss.com>
Tue, 29 Sep 2020 01:12:17 +0000 (18:12 -0700)
committerJustin Weiss <justin@justinweiss.com>
Sat, 10 Oct 2020 22:06:19 +0000 (15:06 -0700)
libpcsxcore/cdriso.c

index c8eacb8..6c6d835 100644 (file)
@@ -1260,14 +1260,19 @@ static void *readThreadMain(void *param) {
       last_read_sector = requested_sector_end;
     }
 
+    index = ra_sector % SECTOR_BUFFER_SIZE;
+
     // check for end of CD
     if (ra_count && ra_sector >= max_sector) {
       ra_count = 0;
+      pthread_mutex_lock(&sectorbuffer_lock);
+      sectorbuffer[index].ret = -1;
+      sectorbuffer[index].sector = ra_sector;
+      pthread_cond_signal(&sectorbuffer_cond);
+      pthread_mutex_unlock(&sectorbuffer_lock);
     }
 
     if (ra_count) {
-
-      index = ra_sector % SECTOR_BUFFER_SIZE;
       pthread_mutex_lock(&sectorbuffer_lock);
       if (sectorbuffer[index].sector != ra_sector) {
         pthread_mutex_unlock(&sectorbuffer_lock);