From 2634909dbd77979ed28db53145b802baf00b130a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laci=20b=C3=A1?= Date: Thu, 26 Aug 2021 21:49:25 +0200 Subject: [PATCH] Fix to avoid undefined behavior at strcpy - Using the `path` buffer to store the directory name, the possible overlapping areas can be avoided at strcpy. - The `path` buffer is unused in further parts of this function, so can be used freely here. The `temp` buffer is too small for this task. --- src/86box.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/86box.c b/src/86box.c index 7611732b6..3f5e897e0 100644 --- a/src/86box.c +++ b/src/86box.c @@ -564,11 +564,14 @@ usage: * At this point usr_path is perfectly initialized. * If no --vmname parameter specified we'll use the * working directory name as the VM's name. + * The directory name will stored in local buffer + * named `path` since it's unused in further parts + * of this function. */ if (strlen(vm_name) == 0) { - plat_get_dirname(vm_name, usr_path); - p = plat_get_filename(vm_name); + plat_get_dirname(path, usr_path); + p = plat_get_filename(path); strcpy(vm_name, p); }