mirror of
https://github.com/facebook/zstd.git
synced 2025-10-08 00:04:02 -04:00
STREAM_WINDOW_MAX : protect streaming from unreasonable memory requirements
This commit is contained in:
parent
70e3b31306
commit
3071c3e303
@ -50,6 +50,16 @@
|
||||
#endif
|
||||
|
||||
|
||||
/*!
|
||||
* STREAM_WINDOW_MAX :
|
||||
* maximum window size accepted by DStream.
|
||||
* frames requiring more memory will be rejected.
|
||||
*/
|
||||
#ifndef ZSTD_STREAM_WINDOW_MAX
|
||||
# define ZSTD_STREAM_WINDOW_MAX (257 << 20) /* 257 MB */
|
||||
#endif
|
||||
|
||||
|
||||
/*-*******************************************************
|
||||
* Dependencies
|
||||
*********************************************************/
|
||||
@ -1445,6 +1455,7 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB
|
||||
/* Frame header instruct buffer sizes */
|
||||
{ size_t const blockSize = MIN(zds->fParams.windowSize, ZSTD_BLOCKSIZE_ABSOLUTEMAX);
|
||||
size_t const neededOutSize = zds->fParams.windowSize + blockSize;
|
||||
if (zds->fParams.windowSize > ZSTD_STREAM_WINDOW_MAX) return ERROR(frameParameter_unsupported);
|
||||
zds->blockSize = blockSize;
|
||||
if (zds->inBuffSize < blockSize) {
|
||||
zds->customMem.customFree(zds->customMem.opaque, zds->inBuff);
|
||||
|
Loading…
x
Reference in New Issue
Block a user