From: Michael Niedermayer <michael@niedermayer.cc> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH 05/17] avcodec/dxva2_*: Initialize dxva_data_ptr Date: Mon, 27 May 2024 01:52:17 +0200 Message-ID: <20240526235230.2876318-5-michael@niedermayer.cc> (raw) In-Reply-To: <20240526235230.2876318-1-michael@niedermayer.cc> Fixes: CID1591888 Uninitialized scalar variable Fixes: CID1591925 Uninitialized pointer read Fixes: CID1591933 Uninitialized scalar variable Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavcodec/dxva2_av1.c | 4 ++-- libavcodec/dxva2_hevc.c | 5 ++++- libavcodec/dxva2_mpeg2.c | 5 ++++- libavcodec/dxva2_vc1.c | 5 ++++- libavcodec/dxva2_vp9.c | 4 ++-- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/libavcodec/dxva2_av1.c b/libavcodec/dxva2_av1.c index 1b555106599..ea97fcb87e5 100644 --- a/libavcodec/dxva2_av1.c +++ b/libavcodec/dxva2_av1.c @@ -354,7 +354,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, const AV1DecContext *h = avctx->priv_data; AVDXVAContext *ctx = DXVA_CONTEXT(avctx); struct av1_dxva2_picture_context *ctx_pic = h->cur_frame.hwaccel_picture_private; - void *dxva_data_ptr; + void *dxva_data_ptr = NULL; uint8_t *dxva_data; unsigned dxva_size; unsigned padding; @@ -382,7 +382,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, dxva_data = dxva_data_ptr; - if (ctx_pic->bitstream_size > dxva_size) { + if (!dxva_data || ctx_pic->bitstream_size > dxva_size) { av_log(avctx, AV_LOG_ERROR, "Bitstream size exceeds hardware buffer"); return -1; } diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c index 31d74a7164d..5eb166c3075 100644 --- a/libavcodec/dxva2_hevc.c +++ b/libavcodec/dxva2_hevc.c @@ -248,7 +248,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, const HEVCFrame *current_picture = h->ref; struct hevc_dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private; DXVA_Slice_HEVC_Short *slice = NULL; - void *dxva_data_ptr; + void *dxva_data_ptr = NULL; uint8_t *dxva_data, *current, *end; unsigned dxva_size; void *slice_data; @@ -278,6 +278,9 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, } #endif + if (!dxva_data_ptr) + return -1; + dxva_data = dxva_data_ptr; current = dxva_data; end = dxva_data + dxva_size; diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c index d31a8bb8724..5de062e5308 100644 --- a/libavcodec/dxva2_mpeg2.c +++ b/libavcodec/dxva2_mpeg2.c @@ -160,7 +160,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, s->current_picture_ptr->hwaccel_picture_private; const int is_field = s->picture_structure != PICT_FRAME; const unsigned mb_count = s->mb_width * (s->mb_height >> is_field); - void *dxva_data_ptr; + void *dxva_data_ptr = NULL; uint8_t *dxva_data, *current, *end; unsigned dxva_size; unsigned i; @@ -186,6 +186,9 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, } #endif + if (!dxva_data_ptr) + return -1; + dxva_data = dxva_data_ptr; current = dxva_data; end = dxva_data + dxva_size; diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c index f7513b2b153..04f26ddff66 100644 --- a/libavcodec/dxva2_vc1.c +++ b/libavcodec/dxva2_vc1.c @@ -197,7 +197,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, const unsigned start_code_size = avctx->codec_id == AV_CODEC_ID_VC1 ? sizeof(start_code) : 0; const unsigned mb_count = s->mb_width * (s->mb_height >> v->field_mode); DXVA_SliceInfo *slice = NULL; - void *dxva_data_ptr; + void *dxva_data_ptr = NULL; uint8_t *dxva_data, *current, *end; unsigned dxva_size; unsigned padding; @@ -224,6 +224,9 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, } #endif + if (!dxva_data_ptr) + return -1; + dxva_data = dxva_data_ptr; current = dxva_data; end = dxva_data + dxva_size; diff --git a/libavcodec/dxva2_vp9.c b/libavcodec/dxva2_vp9.c index ca8b3b136da..f4ab91c580b 100644 --- a/libavcodec/dxva2_vp9.c +++ b/libavcodec/dxva2_vp9.c @@ -172,7 +172,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, const VP9SharedContext *h = avctx->priv_data; AVDXVAContext *ctx = DXVA_CONTEXT(avctx); struct vp9_dxva2_picture_context *ctx_pic = h->frames[CUR_FRAME].hwaccel_picture_private; - void *dxva_data_ptr; + void *dxva_data_ptr = NULL; uint8_t *dxva_data; unsigned dxva_size; unsigned padding; @@ -200,7 +200,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, dxva_data = dxva_data_ptr; - if (ctx_pic->slice.SliceBytesInBuffer > dxva_size) { + if (!dxva_data || ctx_pic->slice.SliceBytesInBuffer > dxva_size) { av_log(avctx, AV_LOG_ERROR, "Failed to build bitstream"); return -1; } -- 2.45.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2024-05-26 23:53 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-05-26 23:52 [FFmpeg-devel] [PATCH 01/17] avcodec/dxva2: Initialize dxva_size and check it Michael Niedermayer 2024-05-26 23:52 ` [FFmpeg-devel] [PATCH 02/17] avcodec/dxva2: Initialize ConfigBitstreamRaw Michael Niedermayer 2024-06-02 19:01 ` Michael Niedermayer 2024-05-26 23:52 ` [FFmpeg-devel] [PATCH 03/17] avcodec/dxva2: initialize validate Michael Niedermayer 2024-05-26 23:52 ` [FFmpeg-devel] [PATCH 04/17] avcodec/dxva2: initialize hr in ff_dxva2_common_end_frame() Michael Niedermayer 2024-06-02 19:10 ` Andreas Rheinhardt 2024-06-02 20:27 ` Michael Niedermayer 2024-07-07 19:48 ` Michael Niedermayer 2024-08-11 10:48 ` Michael Niedermayer 2024-05-26 23:52 ` Michael Niedermayer [this message] 2024-05-26 23:52 ` [FFmpeg-devel] [PATCH 06/17] avcodec/mfenc: check IMFSample_ConvertToContiguousBuffer() for failure Michael Niedermayer 2024-07-02 19:14 ` Michael Niedermayer 2024-05-26 23:52 ` [FFmpeg-devel] [PATCH 07/17] qsv: Initialize impl_value Michael Niedermayer 2024-05-27 2:41 ` Xiang, Haihao 2024-05-26 23:52 ` [FFmpeg-devel] [PATCH 08/17] avcodec/vp8: Check mutex init Michael Niedermayer 2024-06-07 12:00 ` Michael Niedermayer 2024-05-26 23:52 ` [FFmpeg-devel] [PATCH 09/17] avcodec/vp8: Check cond init Michael Niedermayer 2024-05-26 23:52 ` [FFmpeg-devel] [PATCH 10/17] avdevice/dshow: Remove NULL check on pin Michael Niedermayer 2024-05-26 23:52 ` [FFmpeg-devel] [PATCH 11/17] avdevice/dshow: fix badly indented line Michael Niedermayer 2024-05-26 23:52 ` [FFmpeg-devel] [PATCH 12/17] avdevice/dshow: Check device_filter_unique_name before use Michael Niedermayer 2024-05-26 23:52 ` [FFmpeg-devel] [PATCH 13/17] avdevice/dshow: Check ICaptureGraphBuilder2_SetFiltergraph() for failure Michael Niedermayer 2024-07-02 19:16 ` Michael Niedermayer 2024-05-26 23:52 ` [FFmpeg-devel] [PATCH 14/17] avdevice/dshow: Cleanup also on av_log case Michael Niedermayer 2024-07-02 19:20 ` Michael Niedermayer 2024-07-22 17:57 ` Roger Pack 2024-05-26 23:52 ` [FFmpeg-devel] [PATCH 15/17] avdevice/dshow: check ff_dshow_pin_ConnectionMediaType() for failure Michael Niedermayer 2024-05-26 23:52 ` [FFmpeg-devel] [PATCH 16/17] avdevice/dshow: Initialize 2 pointers Michael Niedermayer 2024-06-02 18:58 ` Michael Niedermayer 2024-06-14 23:25 ` Roger Pack 2024-05-26 23:52 ` [FFmpeg-devel] [PATCH 17/17] avdevice/dshow_filter: Use wcscpy_s() Michael Niedermayer 2024-07-12 22:18 ` Michael Niedermayer 2024-05-26 23:56 ` [FFmpeg-devel] [PATCH 01/17] avcodec/dxva2: Initialize dxva_size and check it Michael Niedermayer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240526235230.2876318-5-michael@niedermayer.cc \ --to=michael@niedermayer.cc \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git