Module: wine Branch: master Commit: 4ddb9f691597b71cc083eef0079daf91b224b3ba URL: http://source.winehq.org/git/wine.git/?a=commit;h=4ddb9f691597b71cc083eef007...
Author: Dmitry Timoshkov dmitry@baikal.ru Date: Wed Dec 25 13:24:58 2013 +0900
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.
---
dlls/cabinet/fdi.c | 23 +++++------------------ dlls/cabinet/tests/fdi.c | 5 +---- 2 files changed, 6 insertions(+), 22 deletions(-)
diff --git a/dlls/cabinet/fdi.c b/dlls/cabinet/fdi.c index 2e39444..f9e6522 100644 --- a/dlls/cabinet/fdi.c +++ b/dlls/cabinet/fdi.c @@ -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);
diff --git a/dlls/cabinet/tests/fdi.c b/dlls/cabinet/tests/fdi.c index a2c305d..afae707 100644 --- a/dlls/cabinet/tests/fdi.c +++ b/dlls/cabinet/tests/fdi.c @@ -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);