From d329fbebf0f4394c770adcbb383a698b0a6c7472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Mon, 30 Mar 2015 23:32:32 +0000 Subject: [PATCH] [USETUP]: Add basic installation directory validity check (only for whitespace for now). Patch by Edijs Kolesnikovics, see CORE-6149. Indeed, some ReactOS (and Windows as well) components do not support the system directory having spaces, in particular SMSS: this is due to the basic command-line parsing rules of SMSS that considers that the presence of a space in the command-line is equivalent to a separator, be it in or out a quoted string. svn path=/trunk/; revision=66995 --- reactos/base/setup/usetup/errorcode.h | 3 ++- reactos/base/setup/usetup/filesup.c | 20 ++++++++++++++++++++ reactos/base/setup/usetup/filesup.h | 5 +++++ reactos/base/setup/usetup/interface/usetup.c | 13 +++++++++++++ reactos/base/setup/usetup/lang/bg-BG.h | 6 ++++++ reactos/base/setup/usetup/lang/bn-BD.h | 6 ++++++ reactos/base/setup/usetup/lang/cs-CZ.h | 6 ++++++ reactos/base/setup/usetup/lang/de-DE.h | 8 +++++++- reactos/base/setup/usetup/lang/el-GR.h | 6 ++++++ reactos/base/setup/usetup/lang/en-US.h | 6 ++++++ reactos/base/setup/usetup/lang/es-ES.h | 6 ++++++ reactos/base/setup/usetup/lang/et-EE.h | 6 ++++++ reactos/base/setup/usetup/lang/fr-FR.h | 6 ++++++ reactos/base/setup/usetup/lang/he-IL.h | 6 ++++++ reactos/base/setup/usetup/lang/it-IT.h | 6 ++++++ reactos/base/setup/usetup/lang/ja-JP.h | 6 ++++++ reactos/base/setup/usetup/lang/lt-LT.h | 6 ++++++ reactos/base/setup/usetup/lang/nl-NL.h | 6 ++++++ reactos/base/setup/usetup/lang/pl-PL.h | 6 ++++++ reactos/base/setup/usetup/lang/pt-BR.h | 6 ++++++ reactos/base/setup/usetup/lang/ro-RO.h | 6 ++++++ reactos/base/setup/usetup/lang/ru-RU.h | 6 ++++++ reactos/base/setup/usetup/lang/sk-SK.h | 6 ++++++ reactos/base/setup/usetup/lang/sq-AL.h | 6 ++++++ reactos/base/setup/usetup/lang/sv-SE.h | 6 ++++++ reactos/base/setup/usetup/lang/tr-TR.h | 6 ++++++ reactos/base/setup/usetup/lang/uk-UA.h | 6 ++++++ 27 files changed, 179 insertions(+), 2 deletions(-) diff --git a/reactos/base/setup/usetup/errorcode.h b/reactos/base/setup/usetup/errorcode.h index 2c8b943be0d..373389d8421 100644 --- a/reactos/base/setup/usetup/errorcode.h +++ b/reactos/base/setup/usetup/errorcode.h @@ -66,11 +66,12 @@ typedef enum ERROR_UPDATE_LOCALESETTINGS, ERROR_ADDING_KBLAYOUTS, ERROR_UPDATE_GEOID, + ERROR_DIRECTORY_NAME, ERROR_INSUFFICIENT_PARTITION_SIZE, ERROR_PARTITION_TABLE_FULL, ERROR_ONLY_ONE_EXTENDED, ERROR_LAST_ERROR_CODE -}ERROR_NUMBER; +} ERROR_NUMBER; /* EOF */ diff --git a/reactos/base/setup/usetup/filesup.c b/reactos/base/setup/usetup/filesup.c index b8461e6ad0d..2e70088b0b8 100644 --- a/reactos/base/setup/usetup/filesup.c +++ b/reactos/base/setup/usetup/filesup.c @@ -130,6 +130,26 @@ DoesPathExist( } +BOOLEAN +IsValidPath( + PWCHAR InstallDir, + ULONG Length) +{ + UINT i; + + // TODO: Add check for 8.3 too. + + /* Check for whitespaces */ + for (i = 0; i < Length; i++) + { + if (isspace(InstallDir[i])) + return FALSE; + } + + return TRUE; +} + + NTSTATUS SetupCreateDirectory( PWCHAR PathName) diff --git a/reactos/base/setup/usetup/filesup.h b/reactos/base/setup/usetup/filesup.h index 5522321fbd7..a6ddc354536 100644 --- a/reactos/base/setup/usetup/filesup.h +++ b/reactos/base/setup/usetup/filesup.h @@ -46,4 +46,9 @@ DoesFileExist( PWSTR PathName, PWSTR FileName); +BOOLEAN +IsValidPath( + PWCHAR InstallDir, + ULONG Length); + /* EOF */ diff --git a/reactos/base/setup/usetup/interface/usetup.c b/reactos/base/setup/usetup/interface/usetup.c index 8a5ccdaccc5..1f329abaa01 100644 --- a/reactos/base/setup/usetup/interface/usetup.c +++ b/reactos/base/setup/usetup/interface/usetup.c @@ -2983,6 +2983,10 @@ InstallDirectoryPage(PINPUT_RECORD Ir) CONSOLE_SetInputTextXY(8, 11, 51, InstallDir); MUIDisplayPage(INSTALL_DIRECTORY_PAGE); + // FIXME: Check the validity of the InstallDir; however what to do + // if it is invalid but we are in unattended setup? (case of somebody + // specified an invalid installation directory in the unattended file). + if (IsUnattendedSetup) { return InstallDirectoryPage1(InstallDir, @@ -3004,6 +3008,15 @@ InstallDirectoryPage(PINPUT_RECORD Ir) } else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */ { + /* + * Check for the validity of the installation directory and pop up + * an error if it is not the case. Then the user can fix its input. + */ + if (!IsValidPath(InstallDir, Length)) + { + MUIDisplayError(ERROR_DIRECTORY_NAME, Ir, POPUP_WAIT_ENTER); + return INSTALL_DIRECTORY_PAGE; + } return InstallDirectoryPage1(InstallDir, DiskEntry, PartEntry); diff --git a/reactos/base/setup/usetup/lang/bg-BG.h b/reactos/base/setup/usetup/lang/bg-BG.h index 23dc0bf4d85..d349246a985 100644 --- a/reactos/base/setup/usetup/lang/bg-BG.h +++ b/reactos/base/setup/usetup/lang/bg-BG.h @@ -1505,6 +1505,12 @@ MUI_ERROR bgBGErrorEntries[] = " áâனª â  ­¥ ¬®¦  ¤  ãáâ ­®¢¨ ®§­ ç¨â¥«ï ­  £¥®£à ä᪮⮠¯®«®¦¥­¨¥.\n" "ENTER = १ ¯ã᪠­¥ ­  ª®¬¯îâêà " }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/bn-BD.h b/reactos/base/setup/usetup/lang/bn-BD.h index 4218262d319..61d6dc645d5 100644 --- a/reactos/base/setup/usetup/lang/bn-BD.h +++ b/reactos/base/setup/usetup/lang/bn-BD.h @@ -1492,6 +1492,12 @@ MUI_ERROR bnBDErrorEntries[] = "Setup could not set the geo id.\n" "ENTER = Reboot computer" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/cs-CZ.h b/reactos/base/setup/usetup/lang/cs-CZ.h index f9612b8917d..09c8718f9c9 100644 --- a/reactos/base/setup/usetup/lang/cs-CZ.h +++ b/reactos/base/setup/usetup/lang/cs-CZ.h @@ -1500,6 +1500,12 @@ MUI_ERROR csCZErrorEntries[] = "Nepodaıilo se nastavit geo id.\n" "ENTER = Restartovat poŸ¡taŸ" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/de-DE.h b/reactos/base/setup/usetup/lang/de-DE.h index 7f1e3cc9cc5..9bc2f055f62 100644 --- a/reactos/base/setup/usetup/lang/de-DE.h +++ b/reactos/base/setup/usetup/lang/de-DE.h @@ -1491,11 +1491,17 @@ MUI_ERROR deDEErrorEntries[] = "eingetragen werden.\n" "EINGABETASTE = Computer neu starten" }, - { + { //ERROR_UPDATE_GEOID, "Der geografische Standort konnte nicht eingestellt werden.\n" "EINGABETASTE = Computer neu starten" }, + { + //ERROR_DIRECTORY_NAME, + "Unzul„ssiger Verzeichnisname.\n" + "\n" + " * Eine beliebige Taste zum Fortsetzen drcken." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "Die gew„hlten Partition ist nicht groá genug, um ReactOS zu installieren.\n" diff --git a/reactos/base/setup/usetup/lang/el-GR.h b/reactos/base/setup/usetup/lang/el-GR.h index 52f6c3fb0d0..200b48d8b9f 100644 --- a/reactos/base/setup/usetup/lang/el-GR.h +++ b/reactos/base/setup/usetup/lang/el-GR.h @@ -1523,6 +1523,12 @@ MUI_ERROR elGRErrorEntries[] = "Setup could not set the geo id.\n" "ENTER = Reboot computer" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_PARTITION_TABLE_FULL, "You can not create a new primary or extended partition in the\n" diff --git a/reactos/base/setup/usetup/lang/en-US.h b/reactos/base/setup/usetup/lang/en-US.h index 4cdbb45f6b4..3b5d278a0bc 100644 --- a/reactos/base/setup/usetup/lang/en-US.h +++ b/reactos/base/setup/usetup/lang/en-US.h @@ -1492,6 +1492,12 @@ MUI_ERROR enUSErrorEntries[] = "Setup could not set the geo id.\n" "ENTER = Reboot computer" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/es-ES.h b/reactos/base/setup/usetup/lang/es-ES.h index c0d0d15425f..33eaf7b9f11 100644 --- a/reactos/base/setup/usetup/lang/es-ES.h +++ b/reactos/base/setup/usetup/lang/es-ES.h @@ -1500,6 +1500,12 @@ MUI_ERROR esESErrorEntries[] = "El instalador no ha podido configurar el ID geogr fico.\n" "INTRO = Reiniciar el equipo" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/et-EE.h b/reactos/base/setup/usetup/lang/et-EE.h index 4104224b58c..96d829eb85b 100644 --- a/reactos/base/setup/usetup/lang/et-EE.h +++ b/reactos/base/setup/usetup/lang/et-EE.h @@ -1490,6 +1490,12 @@ MUI_ERROR etEEErrorEntries[] = "Geograafilist asukohta ei ännestunud seadistada.\n" "ENTER = Taask„ivita arvuti" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/fr-FR.h b/reactos/base/setup/usetup/lang/fr-FR.h index b83f658ebb1..09088ad51c9 100644 --- a/reactos/base/setup/usetup/lang/fr-FR.h +++ b/reactos/base/setup/usetup/lang/fr-FR.h @@ -1505,6 +1505,12 @@ MUI_ERROR frFRErrorEntries[] = "Setup n'a pas pu d‚finir la geo id.\n" "ENTRE = Red‚marrer l'ordinateur" }, + { + //ERROR_DIRECTORY_NAME, + "Nom de r‚pertoire invalide.\n" + "\n" + " * Appuyer sur une touche pour continuer." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/he-IL.h b/reactos/base/setup/usetup/lang/he-IL.h index 8e779f8f62f..6265ec03df0 100644 --- a/reactos/base/setup/usetup/lang/he-IL.h +++ b/reactos/base/setup/usetup/lang/he-IL.h @@ -1493,6 +1493,12 @@ MUI_ERROR heILErrorEntries[] = "Setup could not set the geo id.\n" "ENTER = Reboot computer" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/it-IT.h b/reactos/base/setup/usetup/lang/it-IT.h index 185f91dba15..835a9d6343d 100644 --- a/reactos/base/setup/usetup/lang/it-IT.h +++ b/reactos/base/setup/usetup/lang/it-IT.h @@ -1494,6 +1494,12 @@ MUI_ERROR itITErrorEntries[] = "Setup non ha potuto impostare l'id geografico.\n" "INVIO = Riavviare il computer" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/ja-JP.h b/reactos/base/setup/usetup/lang/ja-JP.h index 4d11d82a293..e70f60fa84b 100644 --- a/reactos/base/setup/usetup/lang/ja-JP.h +++ b/reactos/base/setup/usetup/lang/ja-JP.h @@ -1494,6 +1494,12 @@ MUI_ERROR jaJPErrorEntries[] = "¾¯Ä±¯ÌßÊ geo id ¦ ¾¯Ã² ÃŞ·Ï¾İ ÃŞ¼À¡\n" "ENTER = ºİËß­°ÀÉ »²·Ä޳" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/lt-LT.h b/reactos/base/setup/usetup/lang/lt-LT.h index f24c844c6b4..db3689194b3 100644 --- a/reactos/base/setup/usetup/lang/lt-LT.h +++ b/reactos/base/setup/usetup/lang/lt-LT.h @@ -1502,6 +1502,12 @@ MUI_ERROR ltLTErrorEntries[] = "Setup could not set the geo id.\n" "ENTER = Reboot computer" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/nl-NL.h b/reactos/base/setup/usetup/lang/nl-NL.h index e1e9d45708c..1b1ab3efd7d 100644 --- a/reactos/base/setup/usetup/lang/nl-NL.h +++ b/reactos/base/setup/usetup/lang/nl-NL.h @@ -1538,6 +1538,12 @@ MUI_ERROR nlNLErrorEntries[] = "Setup kan de geografische positie niet instellen.\n" "ENTER = Computer opnieuw opstarten" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/pl-PL.h b/reactos/base/setup/usetup/lang/pl-PL.h index c212ae50326..036ccdf458c 100644 --- a/reactos/base/setup/usetup/lang/pl-PL.h +++ b/reactos/base/setup/usetup/lang/pl-PL.h @@ -1502,6 +1502,12 @@ MUI_ERROR plPLErrorEntries[] = "Instalator nie m¢gˆ ustawi† lokalizacji geograficznej.\n" "ENTER = Restart komputera" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/pt-BR.h b/reactos/base/setup/usetup/lang/pt-BR.h index 9b32c9ab36f..c292c4206d3 100644 --- a/reactos/base/setup/usetup/lang/pt-BR.h +++ b/reactos/base/setup/usetup/lang/pt-BR.h @@ -1530,6 +1530,12 @@ MUI_ERROR ptBRErrorEntries[] = "NÆo foi poss¡vel configurar a identifica‡Æo geogr fica.\n" "ENTER=Reiniciar" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/ro-RO.h b/reactos/base/setup/usetup/lang/ro-RO.h index b920a29a3ea..84042caea64 100644 --- a/reactos/base/setup/usetup/lang/ro-RO.h +++ b/reactos/base/setup/usetup/lang/ro-RO.h @@ -1569,6 +1569,12 @@ MUI_ERROR roROErrorEntries[] = "Nu s-a reu­it setarea geo id.", "ENTER = Repornire calculator" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "Partiîia selectatÇ este prea micÇ pentru a instala ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/ru-RU.h b/reactos/base/setup/usetup/lang/ru-RU.h index 42b870642be..709905b3348 100644 --- a/reactos/base/setup/usetup/lang/ru-RU.h +++ b/reactos/base/setup/usetup/lang/ru-RU.h @@ -1493,6 +1493,12 @@ MUI_ERROR ruRUErrorEntries[] = "Setup could not set the geo id.\n" "ENTER = ¥à¥§ £à㧪 " }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/sk-SK.h b/reactos/base/setup/usetup/lang/sk-SK.h index f030e282c07..45fa1c84bfc 100644 --- a/reactos/base/setup/usetup/lang/sk-SK.h +++ b/reactos/base/setup/usetup/lang/sk-SK.h @@ -1504,6 +1504,12 @@ MUI_ERROR skSKErrorEntries[] = "Inçtal tor nemohol nastaviœ geo id.\n" "ENTER = Reçtart poŸ¡taŸa" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/sq-AL.h b/reactos/base/setup/usetup/lang/sq-AL.h index e34084161ca..f6697d9f956 100644 --- a/reactos/base/setup/usetup/lang/sq-AL.h +++ b/reactos/base/setup/usetup/lang/sq-AL.h @@ -1497,6 +1497,12 @@ MUI_ERROR sqALErrorEntries[] = "Instalimi nuk mund t‰ vendosni id geo.\n" "ENTER = Ristarto kompjuterin" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/sv-SE.h b/reactos/base/setup/usetup/lang/sv-SE.h index 6f1f2fe27a6..8c19e785cdb 100644 --- a/reactos/base/setup/usetup/lang/sv-SE.h +++ b/reactos/base/setup/usetup/lang/sv-SE.h @@ -1500,6 +1500,12 @@ MUI_ERROR svSEErrorEntries[] = "Setup kunde inte stalla int 'geo id'.\n" "ENTER = Starta om datorn" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/tr-TR.h b/reactos/base/setup/usetup/lang/tr-TR.h index 7bb8f98548b..3be9ecae6f9 100644 --- a/reactos/base/setup/usetup/lang/tr-TR.h +++ b/reactos/base/setup/usetup/lang/tr-TR.h @@ -1480,6 +1480,12 @@ MUI_ERROR trTRErrorEntries[] = "Kur, co§rƒfŒ kimli§i ayarlayamad.\n" "GiriŸ = Bilgisayar Yeniden BaŸlat" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n" diff --git a/reactos/base/setup/usetup/lang/uk-UA.h b/reactos/base/setup/usetup/lang/uk-UA.h index e83dd37de7e..839d64b1351 100644 --- a/reactos/base/setup/usetup/lang/uk-UA.h +++ b/reactos/base/setup/usetup/lang/uk-UA.h @@ -1500,6 +1500,12 @@ MUI_ERROR ukUAErrorEntries[] = "¥ ¢¤ «®áì ¢áâ ­®¢¨â¨ geo id.\n" "ENTER = ¥à¥§ ¢ ­â ¦¨â¨ ª®¬¯'îâ¥à" }, + { + //ERROR_DIRECTORY_NAME, + "Invalid directory name.\n" + "\n" + " * Press any key to continue." + }, { //ERROR_INSUFFICIENT_PARTITION_SIZE, "The selected partition is not large enough to install ReactOS.\n"