Skip to content

Commit

Permalink
Dependencies: Updated LZMA SDK from 19.00 to 21.02 alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
jsteube committed May 16, 2021
1 parent d08b5b0 commit e365313
Show file tree
Hide file tree
Showing 87 changed files with 10,200 additions and 1,985 deletions.
4 changes: 3 additions & 1 deletion deps/LZMA-SDK/C/7z.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* 7z.h -- 7z interface
2017-04-03 : Igor Pavlov : Public domain */
2018-07-02 : Igor Pavlov : Public domain */

#ifndef __7Z_H
#define __7Z_H
Expand Down Expand Up @@ -91,6 +91,8 @@ typedef struct
UInt64 *CoderUnpackSizes; // for all coders in all folders

Byte *CodersData;

UInt64 RangeLimit;
} CSzAr;

UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex);
Expand Down
44 changes: 28 additions & 16 deletions deps/LZMA-SDK/C/7zArcIn.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* 7zArcIn.c -- 7z Input functions
2018-12-31 : Igor Pavlov : Public domain */
2021-02-09 : Igor Pavlov : Public domain */

#include "Precomp.h"

Expand Down Expand Up @@ -75,15 +75,15 @@ static SRes SzBitUi32s_Alloc(CSzBitUi32s *p, size_t num, ISzAllocPtr alloc)
return SZ_OK;
}

void SzBitUi32s_Free(CSzBitUi32s *p, ISzAllocPtr alloc)
static void SzBitUi32s_Free(CSzBitUi32s *p, ISzAllocPtr alloc)
{
ISzAlloc_Free(alloc, p->Defs); p->Defs = NULL;
ISzAlloc_Free(alloc, p->Vals); p->Vals = NULL;
}

#define SzBitUi64s_Init(p) { (p)->Defs = NULL; (p)->Vals = NULL; }

void SzBitUi64s_Free(CSzBitUi64s *p, ISzAllocPtr alloc)
static void SzBitUi64s_Free(CSzBitUi64s *p, ISzAllocPtr alloc)
{
ISzAlloc_Free(alloc, p->Defs); p->Defs = NULL;
ISzAlloc_Free(alloc, p->Vals); p->Vals = NULL;
Expand All @@ -105,6 +105,8 @@ static void SzAr_Init(CSzAr *p)
p->CoderUnpackSizes = NULL;

p->CodersData = NULL;

p->RangeLimit = 0;
}

static void SzAr_Free(CSzAr *p, ISzAllocPtr alloc)
Expand Down Expand Up @@ -502,7 +504,7 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd)
return SZ_ERROR_ARCHIVE;
if (propsSize >= 0x80)
return SZ_ERROR_UNSUPPORTED;
coder->PropsOffset = sd->Data - dataStart;
coder->PropsOffset = (size_t)(sd->Data - dataStart);
coder->PropsSize = (Byte)propsSize;
sd->Data += (size_t)propsSize;
sd->Size -= (size_t)propsSize;
Expand Down Expand Up @@ -677,7 +679,7 @@ static SRes ReadUnpackInfo(CSzAr *p,
{
UInt32 numCoders, ci, numInStreams = 0;

p->FoCodersOffsets[fo] = sd.Data - startBufPtr;
p->FoCodersOffsets[fo] = (size_t)(sd.Data - startBufPtr);

RINOK(SzReadNumber32(&sd, &numCoders));
if (numCoders == 0 || numCoders > k_Scan_NumCoders_MAX)
Expand Down Expand Up @@ -797,7 +799,7 @@ static SRes ReadUnpackInfo(CSzAr *p,
p->FoToCoderUnpackSizes[fo] = numCodersOutStreams;

{
size_t dataSize = sd.Data - startBufPtr;
const size_t dataSize = (size_t)(sd.Data - startBufPtr);
p->FoStartPackStreamIndex[fo] = packStreamIndex;
p->FoCodersOffsets[fo] = dataSize;
MY_ALLOC_ZE_AND_CPY(p->CodersData, dataSize, startBufPtr, alloc);
Expand Down Expand Up @@ -885,7 +887,7 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi)
if (numStreams != 1 || !SzBitWithVals_Check(&p->FolderCRCs, i))
numSubDigests += numStreams;
}
ssi->sdNumSubStreams.Size = sd->Data - ssi->sdNumSubStreams.Data;
ssi->sdNumSubStreams.Size = (size_t)(sd->Data - ssi->sdNumSubStreams.Data);
continue;
}
if (type == k7zIdCRC || type == k7zIdSize || type == k7zIdEnd)
Expand All @@ -907,7 +909,7 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi)
{
ssi->sdSizes.Data = sd->Data;
RINOK(SkipNumbers(sd, numUnpackSizesInData));
ssi->sdSizes.Size = sd->Data - ssi->sdSizes.Data;
ssi->sdSizes.Size = (size_t)(sd->Data - ssi->sdSizes.Data);
RINOK(ReadID(sd, &type));
}

Expand All @@ -919,7 +921,7 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi)
{
ssi->sdCRCs.Data = sd->Data;
RINOK(SkipBitUi32s(sd, numSubDigests));
ssi->sdCRCs.Size = sd->Data - ssi->sdCRCs.Data;
ssi->sdCRCs.Size = (size_t)(sd->Data - ssi->sdCRCs.Data);
}
else
{
Expand Down Expand Up @@ -947,7 +949,11 @@ static SRes SzReadStreamsInfo(CSzAr *p,
if (type == k7zIdPackInfo)
{
RINOK(ReadNumber(sd, dataOffset));
if (*dataOffset > p->RangeLimit)
return SZ_ERROR_ARCHIVE;
RINOK(ReadPackInfo(p, sd, alloc));
if (p->PackPositions[p->NumPackStreams] > p->RangeLimit - *dataOffset)
return SZ_ERROR_ARCHIVE;
RINOK(ReadID(sd, &type));
}
if (type == k7zIdUnpackInfo)
Expand Down Expand Up @@ -1028,12 +1034,12 @@ static SRes SzReadFileNames(const Byte *data, size_t size, UInt32 numFiles, size
return SZ_ERROR_ARCHIVE;
for (p = data + pos;
#ifdef _WIN32
*(const UInt16 *)p != 0
*(const UInt16 *)(const void *)p != 0
#else
p[0] != 0 || p[1] != 0
#endif
; p += 2);
pos = p - data + 2;
pos = (size_t)(p - data) + 2;
*offsets++ = (pos >> 1);
}
while (--numFiles);
Expand Down Expand Up @@ -1133,6 +1139,8 @@ static SRes SzReadHeader2(
SRes res;

SzAr_Init(&tempAr);
tempAr.RangeLimit = p->db.RangeLimit;

res = SzReadAndDecodePackedStreams(inStream, sd, tempBufs, NUM_ADDITIONAL_STREAMS_MAX,
p->startPosAfterHeader, &tempAr, allocTemp);
*numTempBufs = tempAr.NumFolders;
Expand Down Expand Up @@ -1526,11 +1534,13 @@ static SRes SzArEx_Open2(
nextHeaderSize = GetUi64(header + 20);
nextHeaderCRC = GetUi32(header + 28);

p->startPosAfterHeader = startArcPos + k7zStartHeaderSize;
p->startPosAfterHeader = (UInt64)startArcPos + k7zStartHeaderSize;

if (CrcCalc(header + 12, 20) != GetUi32(header + 8))
return SZ_ERROR_CRC;

p->db.RangeLimit = nextHeaderOffset;

nextHeaderSizeT = (size_t)nextHeaderSize;
if (nextHeaderSizeT != nextHeaderSize)
return SZ_ERROR_MEM;
Expand All @@ -1543,13 +1553,13 @@ static SRes SzArEx_Open2(
{
Int64 pos = 0;
RINOK(ILookInStream_Seek(inStream, &pos, SZ_SEEK_END));
if ((UInt64)pos < startArcPos + nextHeaderOffset ||
(UInt64)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset ||
(UInt64)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize)
if ((UInt64)pos < (UInt64)startArcPos + nextHeaderOffset ||
(UInt64)pos < (UInt64)startArcPos + k7zStartHeaderSize + nextHeaderOffset ||
(UInt64)pos < (UInt64)startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize)
return SZ_ERROR_INPUT_EOF;
}

RINOK(LookInStream_SeekTo(inStream, startArcPos + k7zStartHeaderSize + nextHeaderOffset));
RINOK(LookInStream_SeekTo(inStream, (UInt64)startArcPos + k7zStartHeaderSize + nextHeaderOffset));

if (!Buf_Create(&buf, nextHeaderSizeT, allocTemp))
return SZ_ERROR_MEM;
Expand All @@ -1575,6 +1585,8 @@ static SRes SzArEx_Open2(
Buf_Init(&tempBuf);

SzAr_Init(&tempAr);
tempAr.RangeLimit = p->db.RangeLimit;

res = SzReadAndDecodePackedStreams(inStream, &sd, &tempBuf, 1, p->startPosAfterHeader, &tempAr, allocTemp);
SzAr_Free(&tempAr, allocTemp);

Expand Down
Loading

0 comments on commit e365313

Please sign in to comment.