From bb3c5a6f521b9aa0ab95d57dfb97cd777609fb07 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 15 Jan 2020 02:22:30 +0100 Subject: [PATCH] Fixed a potential overrun in the CD-ROM image backend code. --- src/cdrom/cdrom_image_backend.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cdrom/cdrom_image_backend.c b/src/cdrom/cdrom_image_backend.c index c0f57e810..cb6fd5f82 100644 --- a/src/cdrom/cdrom_image_backend.c +++ b/src/cdrom/cdrom_image_backend.c @@ -149,10 +149,10 @@ bin_init(const wchar_t *filename, int *error) } memset(tf->fn, 0x00, sizeof(tf->fn)); - if (wcslen(tf->fn) > 260) - wcsncpy(tf->fn, filename, 260); - else + if (wcslen(filename) <= 260) wcscpy(tf->fn, filename); + else + wcsncpy(tf->fn, filename, 260); tf->file = plat_fopen64(tf->fn, L"rb"); cdrom_image_backend_log("CDROM: binary_open(%ls) = %08lx\n", tf->fn, tf->file);