[USETUP][REACTOS] Check the status return value of InitDestinationPaths() (#1264)
authorBișoc George <fraizeraust99@gmail.com>
Sun, 10 Feb 2019 15:43:51 +0000 (16:43 +0100)
committerHermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Sun, 10 Feb 2019 15:43:51 +0000 (16:43 +0100)
- Within the function's body code, check the status values returned by the called functions.
- Change the BuildInstallPaths's function type to NTSTATUS instead of VOID (and check the status of InitDestinationPaths() as well.

base/setup/lib/setuplib.c
base/setup/reactos/drivepage.c
base/setup/usetup/usetup.c

index 2b52c46..9e4d22e 100644 (file)
@@ -628,18 +628,29 @@ InitDestinationPaths(
     IN PPARTENTRY PartEntry)    // FIXME: HACK!
 {
     WCHAR PathBuffer[MAX_PATH];
-
-    //
-    // TODO: Check return status values of the functions!
-    //
+    NTSTATUS Status;
 
     /* Create 'pSetupData->DestinationRootPath' string */
     RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
-    RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
-            L"\\Device\\Harddisk%lu\\Partition%lu\\",
-            DiskEntry->DiskNumber,
-            PartEntry->PartitionNumber);
-    RtlCreateUnicodeString(&pSetupData->DestinationRootPath, PathBuffer);
+    Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
+                     L"\\Device\\Harddisk%lu\\Partition%lu\\",
+                     DiskEntry->DiskNumber,
+                     PartEntry->PartitionNumber);
+
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("RtlStringCchPrintfW() failed with status 0x%08lx\n", Status);
+        return Status;
+    }
+
+    Status = RtlCreateUnicodeString(&pSetupData->DestinationRootPath, PathBuffer) ? STATUS_SUCCESS : STATUS_NO_MEMORY;
+
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("RtlCreateUnicodeString() failed with status 0x%08lx\n", Status);
+        return Status;
+    }
+
     DPRINT("DestinationRootPath: %wZ\n", &pSetupData->DestinationRootPath);
 
     // FIXME! Which variable to choose?
@@ -649,23 +660,72 @@ InitDestinationPaths(
 /** Equivalent of 'NTOS_INSTALLATION::SystemArcPath' **/
     /* Create 'pSetupData->DestinationArcPath' */
     RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
-    RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
-            L"multi(0)disk(0)rdisk(%lu)partition(%lu)\\",
-            DiskEntry->BiosDiskNumber,
-            PartEntry->OnDiskPartitionNumber);
-    ConcatPaths(PathBuffer, ARRAYSIZE(PathBuffer), 1, InstallationDir);
-    RtlCreateUnicodeString(&pSetupData->DestinationArcPath, PathBuffer);
+    Status = RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer),
+                     L"multi(0)disk(0)rdisk(%lu)partition(%lu)\\",
+                     DiskEntry->BiosDiskNumber,
+                     PartEntry->OnDiskPartitionNumber);
+
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("RtlStringCchPrintfW() failed with status 0x%08lx\n", Status);
+        RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
+        return Status;
+    }
+
+    Status = ConcatPaths(PathBuffer, ARRAYSIZE(PathBuffer), 1, InstallationDir);
+
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("ConcatPaths() failed with status 0x%08lx\n", Status);
+        RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
+        return Status;
+    }
+
+    Status = RtlCreateUnicodeString(&pSetupData->DestinationArcPath, PathBuffer) ? STATUS_SUCCESS : STATUS_NO_MEMORY;
+
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("RtlCreateUnicodeString() failed with status 0x%08lx\n", Status);
+        RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
+        return Status;
+    }
 
 /** Equivalent of 'NTOS_INSTALLATION::SystemNtPath' **/
     /* Create 'pSetupData->DestinationPath' string */
     RtlFreeUnicodeString(&pSetupData->DestinationPath);
-    CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
-                 pSetupData->DestinationRootPath.Buffer, InstallationDir);
-    RtlCreateUnicodeString(&pSetupData->DestinationPath, PathBuffer);
+    Status = CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 2,
+                          pSetupData->DestinationRootPath.Buffer, InstallationDir);
+
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("CombinePaths() failed with status 0x%08lx\n", Status);
+        RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
+        RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
+        return Status;
+    }
+
+    Status = RtlCreateUnicodeString(&pSetupData->DestinationPath, PathBuffer) ? STATUS_SUCCESS : STATUS_NO_MEMORY;
+
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("RtlCreateUnicodeString() failed with status 0x%08lx\n", Status);
+        RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
+        RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
+        return Status;
+    }
 
 /** Equivalent of 'NTOS_INSTALLATION::PathComponent' **/
     // FIXME: This is only temporary!! Must be removed later!
-    /***/RtlCreateUnicodeString(&pSetupData->InstallPath, InstallationDir);/***/
+    Status = RtlCreateUnicodeString(&pSetupData->InstallPath, InstallationDir) ? STATUS_SUCCESS : STATUS_NO_MEMORY;
+
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("RtlCreateUnicodeString() failed with status 0x%08lx\n", Status);
+        RtlFreeUnicodeString(&pSetupData->DestinationRootPath);
+        RtlFreeUnicodeString(&pSetupData->DestinationArcPath);
+        RtlFreeUnicodeString(&pSetupData->DestinationPath);
+        return Status;
+    }
 
     return STATUS_SUCCESS;
 }
index a1b7d13..b5f07b2 100644 (file)
@@ -33,6 +33,9 @@
 
 #include "resource.h"
 
+#define NDEBUG
+#include <debug.h>
+
 /* GLOBALS ******************************************************************/
 
 #define IDS_LIST_COLUMN_FIRST IDS_PARTITION_NAME
@@ -795,8 +798,11 @@ DisableWizNext:
                     Status = InitDestinationPaths(&pSetupData->USetupData,
                                                   NULL, // pSetupData->USetupData.InstallationDirectory,
                                                   &DiskEntry, &PartEntry);
-                    // TODO: Check Status
-                    UNREFERENCED_PARAMETER(Status);
+
+                    if (!NT_SUCCESS(Status))
+                    {
+                        DPRINT1("InitDestinationPaths() failed with status 0x%08lx\n", Status);
+                    }
 
                     break;
                 }
index 5aeb336..a9a4f81 100644 (file)
@@ -3238,7 +3238,7 @@ CheckFileSystemPage(PINPUT_RECORD Ir)
 }
 
 
-static VOID
+static NTSTATUS
 BuildInstallPaths(PWSTR InstallDir,
                   PDISKENTRY DiskEntry,
                   PPARTENTRY PartEntry)
@@ -3246,11 +3246,17 @@ BuildInstallPaths(PWSTR InstallDir,
     NTSTATUS Status;
 
     Status = InitDestinationPaths(&USetupData, InstallDir, DiskEntry, PartEntry);
-    // TODO: Check Status
-    UNREFERENCED_PARAMETER(Status);
+
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("InitDestinationPaths() failed with status 0x%08lx\n", Status);
+        return Status;
+    }
 
     /* Initialize DestinationDriveLetter */
     DestinationDriveLetter = PartEntry->DriveLetter;
+
+    return STATUS_SUCCESS;
 }