https://git.reactos.org/?p=reactos.git;a=commitdiff;h=469d4dbbab3ae55b87e71…
commit 469d4dbbab3ae55b87e71b583f234fdee0598db9
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Mon Sep 2 14:47:17 2024 +0300
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Fri Sep 20 14:08:13 2024 +0300
[USETUP] Fix handling of 0 sized files in the cab
---
base/setup/usetup/spapisup/cabinet.c | 76 ++++++++++++++++++++----------------
1 file changed, 42 insertions(+), 34 deletions(-)
diff --git a/base/setup/usetup/spapisup/cabinet.c b/base/setup/usetup/spapisup/cabinet.c
index 414008163a5..52c35ed1888 100644
--- a/base/setup/usetup/spapisup/cabinet.c
+++ b/base/setup/usetup/spapisup/cabinet.c
@@ -1104,6 +1104,48 @@ CabinetExtractFile(
}
}
+ if (!ConvertDosDateTimeToFileTime(Search->File->FileDate,
+ Search->File->FileTime,
+ &FileTime))
+ {
+ DPRINT1("DosDateTimeToFileTime() failed\n");
+ Status = CAB_STATUS_CANNOT_WRITE;
+ goto CloseDestFile;
+ }
+
+ NtStatus = NtQueryInformationFile(DestFile,
+ &IoStatusBlock,
+ &FileBasic,
+ sizeof(FILE_BASIC_INFORMATION),
+ FileBasicInformation);
+ if (!NT_SUCCESS(NtStatus))
+ {
+ DPRINT("NtQueryInformationFile() failed (%x)\n", NtStatus);
+ }
+ else
+ {
+ memcpy(&FileBasic.LastAccessTime, &FileTime, sizeof(FILETIME));
+
+ NtStatus = NtSetInformationFile(DestFile,
+ &IoStatusBlock,
+ &FileBasic,
+ sizeof(FILE_BASIC_INFORMATION),
+ FileBasicInformation);
+ if (!NT_SUCCESS(NtStatus))
+ {
+ DPRINT("NtSetInformationFile() failed (%x)\n", NtStatus);
+ }
+ }
+
+ SetAttributesOnFile(Search->File, DestFile);
+
+ /* Nothing more to do for 0 sized files */
+ if (Search->File->FileSize == 0)
+ {
+ Status = CAB_STATUS_SUCCESS;
+ goto CloseDestFile;
+ }
+
MaxDestFileSize.QuadPart = Search->File->FileSize;
NtStatus = NtCreateSection(&DestFileSection,
SECTION_ALL_ACCESS,
@@ -1139,40 +1181,6 @@ CabinetExtractFile(
}
CurrentDestBuffer = DestFileBuffer;
- if (!ConvertDosDateTimeToFileTime(Search->File->FileDate,
- Search->File->FileTime,
- &FileTime))
- {
- DPRINT1("DosDateTimeToFileTime() failed\n");
- Status = CAB_STATUS_CANNOT_WRITE;
- goto UnmapDestFile;
- }
-
- NtStatus = NtQueryInformationFile(DestFile,
- &IoStatusBlock,
- &FileBasic,
- sizeof(FILE_BASIC_INFORMATION),
- FileBasicInformation);
- if (!NT_SUCCESS(NtStatus))
- {
- DPRINT("NtQueryInformationFile() failed (%x)\n", NtStatus);
- }
- else
- {
- memcpy(&FileBasic.LastAccessTime, &FileTime, sizeof(FILETIME));
-
- NtStatus = NtSetInformationFile(DestFile,
- &IoStatusBlock,
- &FileBasic,
- sizeof(FILE_BASIC_INFORMATION),
- FileBasicInformation);
- if (!NT_SUCCESS(NtStatus))
- {
- DPRINT("NtSetInformationFile() failed (%x)\n", NtStatus);
- }
- }
-
- SetAttributesOnFile(Search->File, DestFile);
}
/* Call extract event handler */