mirror of
https://github.com/reactos/reactos.git
synced 2025-06-16 06:08:29 +00:00
[USETUP] Improve the install path checks
- Path must not contain whitespace characters. - Path must be at least 2 characters long. - Path must start with a backslash. - Path must not end with a backslash. - Path components must not end with a dot. CORE-9529
This commit is contained in:
parent
3bf2f30cf2
commit
16daf6700a
1 changed files with 26 additions and 1 deletions
|
@ -140,13 +140,38 @@ IsValidPath(
|
||||||
|
|
||||||
// TODO: Add check for 8.3 too.
|
// TODO: Add check for 8.3 too.
|
||||||
|
|
||||||
/* Check for whitespaces */
|
/* Path must be at least 2 characters long */
|
||||||
|
if (Length < 2)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* Path must start with a backslash */
|
||||||
|
if (InstallDir[0] != L'\\')
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* Path must not end with a backslash */
|
||||||
|
if (InstallDir[Length - 1] == L'\\')
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* Path must not contain whitespace characters */
|
||||||
for (i = 0; i < Length; i++)
|
for (i = 0; i < Length; i++)
|
||||||
{
|
{
|
||||||
if (isspace(InstallDir[i]))
|
if (isspace(InstallDir[i]))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Path component must not end with a dot */
|
||||||
|
for (i = 0; i < Length; i++)
|
||||||
|
{
|
||||||
|
if (InstallDir[i] == L'\\' && i > 0)
|
||||||
|
{
|
||||||
|
if (InstallDir[i - 1] == L'.')
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (InstallDir[Length - 1] == L'.')
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue