From 259abe59dccbdc481ac498a7342b438a2b30c192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 11 Aug 2024 21:04:18 +0200 Subject: [PATCH] [SETUPLIB] Fix the class of characters valid for the installation directory Commit 7c3f4c94a4 (r68307) mentions the valid characters: these are: ASCII alphanumericals (a-z, A-Z, 0-9) (hence the iswalnum() -> isalnum() change), and: '.', '\\', '-', '_' . Spaces are not accepted. Addendum to commit 785cc21598. --- base/setup/lib/setuplib.c | 3 +-- base/setup/lib/setuplib.h | 9 ++++++++- base/setup/usetup/usetup.c | 4 +--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/base/setup/lib/setuplib.c b/base/setup/lib/setuplib.c index 9fb91b24f80..e7c46c433ed 100644 --- a/base/setup/lib/setuplib.c +++ b/base/setup/lib/setuplib.c @@ -731,8 +731,7 @@ IsValidInstallDirectory( if (!*p || (IS_PATH_SEPARATOR(*p) && !*(p + 1))) return FALSE; - /* The path must contain only valid characters (alpha-numeric, - * '.', '\\', '-' and '_'). Spaces are not accepted. */ + /* The path must contain only valid characters */ for (p = InstallDir; *p; ++p) { if (!IS_VALID_INSTALL_PATH_CHAR(*p)) diff --git a/base/setup/lib/setuplib.h b/base/setup/lib/setuplib.h index 43fe3a866f9..4272138cac6 100644 --- a/base/setup/lib/setuplib.h +++ b/base/setup/lib/setuplib.h @@ -177,8 +177,15 @@ InitSystemPartition( _In_opt_ PFSVOL_CALLBACK FsVolCallback, _In_opt_ PVOID Context); +/** + * @brief + * Defines the class of characters valid for the installation directory. + * + * The valid characters are: ASCII alphanumericals (a-z, A-Z, 0-9), + * and: '.', '\\', '-', '_' . Spaces are not allowed. + **/ #define IS_VALID_INSTALL_PATH_CHAR(c) \ - (iswalnum(c) || (c) == L'.' || (c) == L'\\' || (c) == L'-' || (c) == L'_') + (isalnum(c) || (c) == L'.' || (c) == L'\\' || (c) == L'-' || (c) == L'_') BOOLEAN IsValidInstallDirectory( diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c index 204c92715c1..e6025854e8e 100644 --- a/base/setup/usetup/usetup.c +++ b/base/setup/usetup/usetup.c @@ -3060,9 +3060,7 @@ InstallDirectoryPage(PINPUT_RECORD Ir) { if (Length < 50) { - /* Only accept valid characters for installation path - * (alpha-numeric, '.', '\', '-' and '_'). Note that - * spaces are not accepted. */ + /* Only accept valid characters for the installation path */ c = (WCHAR)Ir->Event.KeyEvent.uChar.AsciiChar; if (IS_VALID_INSTALL_PATH_CHAR(c)) {