[FREELDR] Some initialization fixes.

- Initialize BootPath and BootOptions buffers when fallback behaviour is not taken.
- Correctly skip all the understood whitespace (space & tabs) and the
  quotes before reading the boot options when using the alternative syntax:

  [Operating Systems]
  section_name = "ReactOS" /bootoptions

  Fixes the minor regression introduced in 370e8564 (r43875).
This commit is contained in:
Hermès Bélusca-Maïto 2019-08-04 17:35:46 +02:00
parent b978d42bd9
commit 909bfff460
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 33 additions and 15 deletions

View file

@ -191,6 +191,7 @@ LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem,
UiDrawProgressBarCenter(1, 100, "Loading ReactOS Setup...");
/* Read the system path is set in the .ini file */
BootPath[0] = ANSI_NULL;
if (!HasSection || !IniReadSettingByName(SectionId, "SystemPath", BootPath, sizeof(BootPath)))
{
/*
@ -231,15 +232,23 @@ LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem,
if ((strlen(BootPath) == 0) || BootPath[strlen(BootPath) - 1] != '\\')
strcat(BootPath, "\\");
/* Read booting options */
/* Read boot options */
BootOptions2[0] = ANSI_NULL;
if (!HasSection || !IniReadSettingByName(SectionId, "Options", BootOptions2, sizeof(BootOptions2)))
{
/* Get options after the title */
/* Retrieve the options after the quoted title */
PCSTR p = SettingsValue;
while (*p == ' ' || *p == '"')
p++;
while (*p != '\0' && *p != '"')
p++;
/* Trim any leading whitespace and quotes */
while (*p == ' ' || *p == '\t' || *p == '"')
++p;
/* Skip all the text up to the first last quote */
while (*p != ANSI_NULL && *p != '"')
++p;
/* Trim any trailing whitespace and quotes */
while (*p == ' ' || *p == '\t' || *p == '"')
++p;
strcpy(BootOptions2, p);
TRACE("BootOptions: '%s'\n", BootOptions2);
}

View file

@ -652,13 +652,13 @@ LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem,
{
ULONG_PTR SectionId;
PCSTR SectionName = OperatingSystem->SystemPartition;
CHAR SettingsValue[80];
PCHAR File;
BOOLEAN Success;
BOOLEAN HasSection;
CHAR SettingsValue[80];
CHAR BootPath[MAX_PATH];
CHAR FileName[MAX_PATH];
CHAR BootOptions[256];
PCHAR File;
BOOLEAN Success;
PLOADER_PARAMETER_BLOCK LoaderBlock;
/* Get OS setting value */
@ -673,6 +673,7 @@ LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem,
UiDrawProgressBarCenter(1, 100, "Loading NT...");
/* Read the system path is set in the .ini file */
BootPath[0] = ANSI_NULL;
if (!HasSection || !IniReadSettingByName(SectionId, "SystemPath", BootPath, sizeof(BootPath)))
{
strcpy(BootPath, SectionName);
@ -704,15 +705,23 @@ LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem,
if ((BootPath[0] == 0) || BootPath[strlen(BootPath) - 1] != '\\')
strcat(BootPath, "\\");
/* Read booting options */
/* Read boot options */
BootOptions[0] = ANSI_NULL;
if (!HasSection || !IniReadSettingByName(SectionId, "Options", BootOptions, sizeof(BootOptions)))
{
/* Get options after the title */
/* Retrieve the options after the quoted title */
PCSTR p = SettingsValue;
while (*p == ' ' || *p == '"')
p++;
while (*p != '\0' && *p != '"')
p++;
/* Trim any leading whitespace and quotes */
while (*p == ' ' || *p == '\t' || *p == '"')
++p;
/* Skip all the text up to the first last quote */
while (*p != ANSI_NULL && *p != '"')
++p;
/* Trim any trailing whitespace and quotes */
while (*p == ' ' || *p == '\t' || *p == '"')
++p;
strcpy(BootOptions, p);
TRACE("BootOptions: '%s'\n", BootOptions);
}