From: Yann Collet Date: Fri, 24 Mar 2017 00:59:50 +0000 (-0700) Subject: fixed ERROR_GENERIC on dstSize_tooSmall X-Git-Tag: v1.2.0^2~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23776ce29022a68170e4cbea042f5616a4093507;p=thirdparty%2Fzstd.git fixed ERROR_GENERIC on dstSize_tooSmall required by users which depends on this error code to size dest buffer --- diff --git a/lib/compress/fse_compress.c b/lib/compress/fse_compress.c index 6708fb9d7..e520e802b 100644 --- a/lib/compress/fse_compress.c +++ b/lib/compress/fse_compress.c @@ -291,7 +291,7 @@ static size_t FSE_writeNCount_generic (void* header, size_t headerBufferSize, size_t FSE_writeNCount (void* buffer, size_t bufferSize, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog) { - if (tableLog > FSE_MAX_TABLELOG) return ERROR(GENERIC); /* Unsupported */ + if (tableLog > FSE_MAX_TABLELOG) return ERROR(tableLog_tooLarge); /* Unsupported */ if (tableLog < FSE_MIN_TABLELOG) return ERROR(GENERIC); /* Unsupported */ if (bufferSize < FSE_NCountWriteBound(maxSymbolValue, tableLog)) diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 1aab3553f..b37425dad 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -653,7 +653,7 @@ MEM_STATIC size_t ZSTD_compressSequences (ZSTD_CCtx* zc, if (count[llCodeTable[nbSeq-1]]>1) { count[llCodeTable[nbSeq-1]]--; nbSeq_1--; } FSE_normalizeCount(norm, tableLog, count, nbSeq_1, max); { size_t const NCountSize = FSE_writeNCount(op, oend-op, norm, max, tableLog); /* overflow protected */ - if (FSE_isError(NCountSize)) return ERROR(GENERIC); + if (FSE_isError(NCountSize)) return NCountSize; op += NCountSize; } FSE_buildCTable_wksp(CTable_LitLength, norm, max, tableLog, scratchBuffer, sizeof(scratchBuffer)); LLtype = set_compressed; @@ -677,7 +677,7 @@ MEM_STATIC size_t ZSTD_compressSequences (ZSTD_CCtx* zc, if (count[ofCodeTable[nbSeq-1]]>1) { count[ofCodeTable[nbSeq-1]]--; nbSeq_1--; } FSE_normalizeCount(norm, tableLog, count, nbSeq_1, max); { size_t const NCountSize = FSE_writeNCount(op, oend-op, norm, max, tableLog); /* overflow protected */ - if (FSE_isError(NCountSize)) return ERROR(GENERIC); + if (FSE_isError(NCountSize)) return NCountSize; op += NCountSize; } FSE_buildCTable_wksp(CTable_OffsetBits, norm, max, tableLog, scratchBuffer, sizeof(scratchBuffer)); Offtype = set_compressed; @@ -701,7 +701,7 @@ MEM_STATIC size_t ZSTD_compressSequences (ZSTD_CCtx* zc, if (count[mlCodeTable[nbSeq-1]]>1) { count[mlCodeTable[nbSeq-1]]--; nbSeq_1--; } FSE_normalizeCount(norm, tableLog, count, nbSeq_1, max); { size_t const NCountSize = FSE_writeNCount(op, oend-op, norm, max, tableLog); /* overflow protected */ - if (FSE_isError(NCountSize)) return ERROR(GENERIC); + if (FSE_isError(NCountSize)) return NCountSize; op += NCountSize; } FSE_buildCTable_wksp(CTable_MatchLength, norm, max, tableLog, scratchBuffer, sizeof(scratchBuffer)); MLtype = set_compressed;