From: Quim Rovira Date: Mon, 15 Aug 2016 16:05:21 +0000 (+0200) Subject: Allow only window values between kBrotliMinWindowBits and kBrotliMaxindowBits X-Git-Tag: 0.002~18 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=9d6eec245de326a70986bd7098753569f6a1aa1e;p=io-compress-brotli.git Allow only window values between kBrotliMinWindowBits and kBrotliMaxindowBits --- diff --git a/Brotli.xs b/Brotli.xs index c466019..8de3dd5 100644 --- a/Brotli.xs +++ b/Brotli.xs @@ -102,7 +102,10 @@ SV* bro(buffer, quality=BROTLI_DEFAULT_QUALITY, lgwin=BROTLI_DEFAULT_WINDOW) BROTLI_BOOL result; CODE: if( quality < BROTLI_MIN_QUALITY || quality > BROTLI_MAX_QUALITY ) { - croak("Invalid quality value"); + croak("Invalid quality value"); + } + if( lgwin < kBrotliMinWindowBits || lgwin > kBrotliMaxWindowBits ) { + croak("Invalid window value"); } decoded_buffer = (uint8_t*) SvPV(buffer, decoded_size); encoded_size = BrotliEncoderMaxCompressedSize(decoded_size); @@ -137,6 +140,9 @@ SV* BrotliEncoderSetWindow(state, window) SV* state U32 window CODE: + if( window < kBrotliMinWindowBits || window > kBrotliMaxWindowBits ) { + croak("Invalid window value"); + } if( BrotliEncoderSetParameter((BrotliEncoderState*) SvIV(state), BROTLI_PARAM_LGWIN, window) ) RETVAL = newSVuv(1); else @@ -149,7 +155,7 @@ SV* BrotliEncoderSetQuality(state, quality) U32 quality CODE: if( quality < BROTLI_MIN_QUALITY || quality > BROTLI_MAX_QUALITY ) { - croak("Invalid quality value"); + croak("Invalid quality value"); } if( BrotliEncoderSetParameter((BrotliEncoderState*) SvIV(state), BROTLI_PARAM_QUALITY, quality) ) RETVAL = newSVuv(1);