cabinet: Read CAB size from the file header instead of calling FDI seek callback with SEEK_END.

SEEK_END is not supported by some callback implementations.
oldstable
Dmitry Timoshkov 2013-12-25 13:24:58 +09:00 committed by Alexandre Julliard
parent 3cb5b93db9
commit 4ddb9f6915
2 changed files with 6 additions and 22 deletions

View File

@ -536,7 +536,7 @@ static BOOL FDI_read_entries(
PMORE_ISCAB_INFO pmii)
{
int num_folders, num_files, header_resv, folder_resv = 0;
LONG base_offset, cabsize;
LONG cabsize;
USHORT setid, cabidx, flags;
cab_UBYTE buf[64], block_resv;
char *prevname = NULL, *previnfo = NULL, *nextname = NULL, *nextinfo = NULL;
@ -573,34 +573,21 @@ static BOOL FDI_read_entries(
* -gmt
*/
/* get basic offset & size info */
base_offset = FDI_getoffset(fdi, hf);
if (fdi->seek(hf, 0, SEEK_END) == -1) {
if (pmii) set_error( fdi, FDIERROR_NOT_A_CABINET, 0 );
return FALSE;
}
cabsize = FDI_getoffset(fdi, hf);
if ((cabsize == -1) || (base_offset == -1) ||
( fdi->seek(hf, base_offset, SEEK_SET) == -1 )) {
if (pmii) set_error( fdi, FDIERROR_NOT_A_CABINET, 0 );
return FALSE;
}
/* read in the CFHEADER */
if (fdi->read(hf, buf, cfhead_SIZEOF) != cfhead_SIZEOF) {
if (pmii) set_error( fdi, FDIERROR_NOT_A_CABINET, 0 );
return FALSE;
}
/* check basic MSCF signature */
if (EndGetI32(buf+cfhead_Signature) != 0x4643534d) {
if (pmii) set_error( fdi, FDIERROR_NOT_A_CABINET, 0 );
return FALSE;
}
/* get the cabinet size */
cabsize = EndGetI32(buf+cfhead_CabinetSize);
/* get the number of folders */
num_folders = EndGetI16(buf+cfhead_NumFolders);

View File

@ -762,7 +762,6 @@ static LONG CDECL fdi_mem_seek(INT_PTR hf, LONG dist, int seektype)
case SEEK_END:
default:
todo_wine
ok(0, "seek: not expected type %d\n", seektype);
return -1;
}
@ -879,18 +878,16 @@ static void test_FDICopy(void)
memset(&info, 0, sizeof(info));
ret = FDIIsCabinet(hfdi, fd, &info);
todo_wine {
ok(ret, "FDIIsCabinet error %d\n", erf.erfOper);
ok(info.cbCabinet == 0x59, "expected 0x59, got %#x\n", info.cbCabinet);
ok(info.cFiles == 1, "expected 1, got %d\n", info.cFiles);
ok(info.cFolders == 1, "expected 1, got %d\n", info.cFolders);
ok(info.setID == 0x1225, "expected 0x1225, got %#x\n", info.setID);
ok(info.iCabinet == 0x2013, "expected 0x2013, got %#x\n", info.iCabinet);
}
fdi_mem_close(fd);
ret = FDICopy(hfdi, block, memory, 0, fdi_mem_notify, NULL, 0);
todo_wine
ok(ret, "FDICopy error %d\n", erf.erfOper);
FDIDestroy(hfdi);