LZMA SDK (C) decompress srcLen output

53 Views Asked by At

I'm trying to implement decompression with LZMA SDK in C with limited memory resources. I struggle when receiving an output size that I don't understand.

Sometimes when I try to decompress incoming data, the srcLen (inProcessed in my example) is larger after calling LzmaDec_DecodeToBuf.

static uint8_t storage_buffer[2000];

outProccessed = 2000;
inProcessed = 32;

res = LzmaDec_DecodeToBuf(state, storage_buffer, outProccessed, input_buffer, inProcessed, finishMode, &status);

if (res == SZ_OK && inProcessed == 32)
{
   return 0; /* Everything processed and OK! */
}

if (inProcessed > 32)
{
   /* inProccessed is larger. What to do? */
}
else if (inProcessed < 32)
{
   /* Need to take care of the data not processed */
}

When inProcessed is smaller than the input, I know that I need to take care of the not processed data in input_buffer. But I don't know what to do when inProcessed is larger then it was before.

E.g. inProcessed is 32 when calling LzmaDec_DecodeToBuf, but LzmaDec_DecodeToBuf is changeing it to 36 after processing.

As input_buffer only have 32 bytes of data, I dont see how and why LzmaDec_DecodeToBuf is taking more data than provided?

The implementation works for most of the times, but in some cases of decompression its not working and I dont know why.

0

There are 0 best solutions below