Skip to content

Commit

Permalink
[core/lzma] Properly account for kHeaderSize
Browse files Browse the repository at this point in the history
lzma_code must only see the buffers without the header, so the sizes
have to be adjusted accordingly.

Fixes root-project#14508
  • Loading branch information
hahnjo committed Feb 8, 2024
1 parent 44d1c23 commit 17e3561
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/lzma/src/ZipLZMA.c
Expand Up @@ -68,7 +68,7 @@ void R__zipLZMA(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, i
stream.avail_in = (size_t)(*srcsize);

stream.next_out = (uint8_t *)(&tgt[kHeaderSize]);
stream.avail_out = (size_t)(*tgtsize);
stream.avail_out = (size_t)(*tgtsize) - kHeaderSize;

returnStatus = lzma_code(&stream, LZMA_FINISH);
if (returnStatus != LZMA_STREAM_END) {
Expand Down Expand Up @@ -117,7 +117,7 @@ void R__unzipLZMA(int *srcsize, unsigned char *src, int *tgtsize, unsigned char
}

stream.next_in = (const uint8_t *)(&src[kHeaderSize]);
stream.avail_in = (size_t)(*srcsize);
stream.avail_in = (size_t)(*srcsize) - kHeaderSize;
stream.next_out = (uint8_t *)tgt;
stream.avail_out = (size_t)(*tgtsize);

Expand Down

0 comments on commit 17e3561

Please sign in to comment.