From 1d2721b9bd4377d3b4917c325f362f5bf43053b9 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 15 Jan 2020 00:43:51 +0100 Subject: [PATCH] Fixed a potential overrun in the Intel flash code. --- src/intel_flash.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/intel_flash.c b/src/intel_flash.c index 4dd041a48..faddf4ec4 100644 --- a/src/intel_flash.c +++ b/src/intel_flash.c @@ -330,7 +330,10 @@ intel_flash_init(const device_t *info) flash_name = (wchar_t *)malloc(l*sizeof(wchar_t)); swprintf(flash_name, l, L"%ls.bin", machine_name); - wcscpy(flash_path, flash_name); + if (wcslen(flash_name) <= 1024) + wcscpy(flash_path, flash_name); + else + wcsncpy(flash_path, flash_name, 1024); dev->flags = info->local & 0xff;