Commit 33e561f5 authored by Vitaly Perov's avatar Vitaly Perov Committed by Alexandre Julliard

cabinet: Fix for FDICopy with an empty cabinet file.

parent 10772381
...@@ -562,9 +562,14 @@ static BOOL FDI_read_entries( ...@@ -562,9 +562,14 @@ static BOOL FDI_read_entries(
/* get the number of folders */ /* get the number of folders */
num_folders = EndGetI16(buf+cfhead_NumFolders); num_folders = EndGetI16(buf+cfhead_NumFolders);
if (num_folders == 0) { /* if num_folders is 0, it's correct cab, but empty */
/* PONDERME: is this really invalid? */ /* if num_folders is 1, there is no folders in this cab */
WARN("weird cabinet detect failure: no folders in cabinet\n");
/* get the number of files */
num_files = EndGetI16(buf+cfhead_NumFiles);
if (num_files && !num_folders) {
/* If there at least one file in the cabinet. num_folders is always >= 1 */
WARN("weird cabinet detect failure: cabinet is not empty, but num_folders = 0\n");
if (pmii) { if (pmii) {
PFDI_INT(hfdi)->perf->erfOper = FDIERROR_NOT_A_CABINET; PFDI_INT(hfdi)->perf->erfOper = FDIERROR_NOT_A_CABINET;
PFDI_INT(hfdi)->perf->erfType = 0; PFDI_INT(hfdi)->perf->erfType = 0;
...@@ -572,12 +577,9 @@ static BOOL FDI_read_entries( ...@@ -572,12 +577,9 @@ static BOOL FDI_read_entries(
} }
return FALSE; return FALSE;
} }
if (!num_files && num_folders) {
/* get the number of files */ /* If cabinet consist of 0 files, num_folders must be 0 */
num_files = EndGetI16(buf+cfhead_NumFiles); WARN("weird cabinet detect failure: no files in cabinet, but there are folders\n");
if (num_files == 0) {
/* PONDERME: is this really invalid? */
WARN("weird cabinet detect failure: no files in cabinet\n");
if (pmii) { if (pmii) {
PFDI_INT(hfdi)->perf->erfOper = FDIERROR_NOT_A_CABINET; PFDI_INT(hfdi)->perf->erfOper = FDIERROR_NOT_A_CABINET;
PFDI_INT(hfdi)->perf->erfType = 0; PFDI_INT(hfdi)->perf->erfType = 0;
...@@ -2834,6 +2836,11 @@ BOOL __cdecl FDICopy( ...@@ -2834,6 +2836,11 @@ BOOL __cdecl FDICopy(
} }
/* free decompression temps */ /* free decompression temps */
if (!fol) {
/* Empty cabinet */
PFDI_CLOSE(hfdi, cabhf);
return TRUE; /* empty, but correct */
}
switch (fol->comp_type & cffoldCOMPTYPE_MASK) { switch (fol->comp_type & cffoldCOMPTYPE_MASK) {
case cffoldCOMPTYPE_LZX: case cffoldCOMPTYPE_LZX:
if (LZX(window)) { if (LZX(window)) {
......
...@@ -627,10 +627,7 @@ static void test_FDICopy(void) ...@@ -627,10 +627,7 @@ static void test_FDICopy(void)
cpuUNKNOWN, &erf); cpuUNKNOWN, &erf);
ret=FDICopy(hfdi, name, path, 0, CopyProgress, NULL, 0); ret=FDICopy(hfdi, name, path, 0, CopyProgress, NULL, 0);
todo_wine ok(ret, "Expected FDICopy to succeed\n");
{
ok(ret, "Expected FDICopy to succeed\n");
}
FDIDestroy(hfdi); FDIDestroy(hfdi);
DeleteFileA(name); DeleteFileA(name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment