diff options
Diffstat (limited to 'libavcodec/rscc.c')
-rw-r--r-- | libavcodec/rscc.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/libavcodec/rscc.c b/libavcodec/rscc.c index 4a91783..fe0df2e 100644 --- a/libavcodec/rscc.c +++ b/libavcodec/rscc.c @@ -2,20 +2,20 @@ * innoHeim/Rsupport Screen Capture Codec * Copyright (C) 2015 Vittorio Giovara <vittorio.giovara@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -106,8 +106,9 @@ static av_cold int rscc_init(AVCodecContext *avctx) return AVERROR_INVALIDDATA; } } else { - av_log(avctx, AV_LOG_ERROR, "Invalid codec tag\n"); - return AVERROR_INVALIDDATA; + avctx->pix_fmt = AV_PIX_FMT_BGR0; + ctx->component_size = 4; + av_log(avctx, AV_LOG_WARNING, "Invalid codec tag\n"); } /* Store the value to check for keyframes */ @@ -247,11 +248,27 @@ static int rscc_decode_frame(AVCodecContext *avctx, void *data, ff_dlog(avctx, "pixel_size %d packed_size %d.\n", pixel_size, packed_size); + if (packed_size < 0) { + av_log(avctx, AV_LOG_ERROR, "Invalid tile size %d\n", packed_size); + ret = AVERROR_INVALIDDATA; + goto end; + } + /* Get pixels buffer, it may be deflated or just raw */ if (pixel_size == packed_size) { + if (bytestream2_get_bytes_left(gbc) < pixel_size) { + av_log(avctx, AV_LOG_ERROR, "Insufficient input for %d\n", pixel_size); + ret = AVERROR_INVALIDDATA; + goto end; + } pixels = gbc->buffer; } else { uLongf len = ctx->inflated_size; + if (bytestream2_get_bytes_left(gbc) < packed_size) { + av_log(avctx, AV_LOG_ERROR, "Insufficient input for %d\n", packed_size); + ret = AVERROR_INVALIDDATA; + goto end; + } ret = uncompress(ctx->inflated_buf, &len, gbc->buffer, packed_size); if (ret) { av_log(avctx, AV_LOG_ERROR, "Pixel deflate error %d.\n", ret); |