From a1b0d535e13d7fbc69f73b5d81d41ded0d08f2d9 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 8 Aug 2025 19:55:53 +0200 Subject: [PATCH] Windows CD-ROM IOCTL: Do not pass to big maximum size values to the READ TOC IOCTL's, fixes #5900. --- src/qt/win_cdrom_ioctl.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/qt/win_cdrom_ioctl.c b/src/qt/win_cdrom_ioctl.c index cd558c2ec..6bc2df27c 100644 --- a/src/qt/win_cdrom_ioctl.c +++ b/src/qt/win_cdrom_ioctl.c @@ -49,6 +49,13 @@ typedef struct ioctl_t { WCHAR path[256]; } ioctl_t; +typedef struct _CDROM_FULL_TOC { + UCHAR Length[2]; + UCHAR FirstCompleteSession; + UCHAR LastCompleteSession; + CDROM_TOC_FULL_TOC_DATA_BLOCK Descriptors[MAXIMUM_NUMBER_TRACKS + 2]; +} CDROM_FULL_TOC; + static int ioctl_read_dvd_structure(const void *local, uint8_t layer, uint8_t format, uint8_t *buffer, uint32_t *info); @@ -124,7 +131,7 @@ ioctl_read_normal_toc(ioctl_t *ioctl, uint8_t *toc_buf, int32_t *tracks_num) const int temp = DeviceIoControl(ioctl->handle, IOCTL_CDROM_READ_TOC_EX, &cur_read_toc_ex, sizeof(CDROM_READ_TOC_EX), - cur_full_toc, 65535, + cur_full_toc, sizeof(CDROM_TOC), (LPDWORD) &size, NULL); ioctl_log(ioctl->log, "temp = %i\n", temp); @@ -179,7 +186,7 @@ ioctl_read_raw_toc(ioctl_t *ioctl) if (!ioctl->is_dvd) { status = DeviceIoControl(ioctl->handle, IOCTL_CDROM_READ_TOC_EX, &cur_read_toc_ex, sizeof(CDROM_READ_TOC_EX), - cur_full_toc, 65535, + cur_full_toc, sizeof(CDROM_FULL_TOC), (LPDWORD) &size, NULL); ioctl_log(ioctl->log, "status = %i\n", status); }