avcodec/cscd: Fix "CamStudio Lossless Codec 1.0" gzip files
Fixes: tickets/10241/cscd_1_0_306_306_gzip.avi Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit ab7d38f970674e6765b5e1adb911c1763b9ce806) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
		
							parent
							
								
									10212e7a0f
								
							
						
					
					
						commit
						e93ee8f8d8
					
				@ -71,6 +71,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
 | 
				
			|||||||
    int buf_size = avpkt->size;
 | 
					    int buf_size = avpkt->size;
 | 
				
			||||||
    CamStudioContext *c = avctx->priv_data;
 | 
					    CamStudioContext *c = avctx->priv_data;
 | 
				
			||||||
    int ret;
 | 
					    int ret;
 | 
				
			||||||
 | 
					    int bpp = avctx->bits_per_coded_sample / 8;
 | 
				
			||||||
 | 
					    int bugdelta = FFALIGN(avctx->width * bpp, 4)       * avctx->height
 | 
				
			||||||
 | 
					                 -        (avctx->width     & ~3) * bpp * avctx->height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (buf_size < 2) {
 | 
					    if (buf_size < 2) {
 | 
				
			||||||
        av_log(avctx, AV_LOG_ERROR, "coded frame too small\n");
 | 
					        av_log(avctx, AV_LOG_ERROR, "coded frame too small\n");
 | 
				
			||||||
@ -84,9 +87,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
 | 
				
			|||||||
    switch ((buf[0] >> 1) & 7) {
 | 
					    switch ((buf[0] >> 1) & 7) {
 | 
				
			||||||
    case 0: { // lzo compression
 | 
					    case 0: { // lzo compression
 | 
				
			||||||
        int outlen = c->decomp_size, inlen = buf_size - 2;
 | 
					        int outlen = c->decomp_size, inlen = buf_size - 2;
 | 
				
			||||||
        int bpp = avctx->bits_per_coded_sample / 8;
 | 
					 | 
				
			||||||
        int bugdelta = FFALIGN(avctx->width * bpp, 4)       * avctx->height
 | 
					 | 
				
			||||||
                     -        (avctx->width     & ~3) * bpp * avctx->height;
 | 
					 | 
				
			||||||
        if (av_lzo1x_decode(c->decomp_buf, &outlen, &buf[2], &inlen) || (outlen && outlen != bugdelta)) {
 | 
					        if (av_lzo1x_decode(c->decomp_buf, &outlen, &buf[2], &inlen) || (outlen && outlen != bugdelta)) {
 | 
				
			||||||
            av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
 | 
					            av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
 | 
				
			||||||
            return AVERROR_INVALIDDATA;
 | 
					            return AVERROR_INVALIDDATA;
 | 
				
			||||||
@ -96,7 +96,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
 | 
				
			|||||||
    case 1: { // zlib compression
 | 
					    case 1: { // zlib compression
 | 
				
			||||||
#if CONFIG_ZLIB
 | 
					#if CONFIG_ZLIB
 | 
				
			||||||
        unsigned long dlen = c->decomp_size;
 | 
					        unsigned long dlen = c->decomp_size;
 | 
				
			||||||
        if (uncompress(c->decomp_buf, &dlen, &buf[2], buf_size - 2) != Z_OK || dlen != c->decomp_size) {
 | 
					        if (uncompress(c->decomp_buf, &dlen, &buf[2], buf_size - 2) != Z_OK || (dlen != c->decomp_size && dlen != c->decomp_size - bugdelta)) {
 | 
				
			||||||
            av_log(avctx, AV_LOG_ERROR, "error during zlib decompression\n");
 | 
					            av_log(avctx, AV_LOG_ERROR, "error during zlib decompression\n");
 | 
				
			||||||
            return AVERROR_INVALIDDATA;
 | 
					            return AVERROR_INVALIDDATA;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user