* [FFmpeg-devel] [PATCH 1/2] avcodec/hevc/hevcdec: ensure a bit was read when checking for alignment_bit_equal_to_one
@ 2025-05-02 19:28 James Almer
2025-05-02 19:28 ` [FFmpeg-devel] [PATCH 2/2] avcodec/hevc/hevcdec: move the slice header buffer overread check up in the function James Almer
0 siblings, 1 reply; 2+ messages in thread
From: James Almer @ 2025-05-02 19:28 UTC (permalink / raw)
To: ffmpeg-devel
Prevents printing bogus errors about the value being 0, when in fact we
overread the available slice buffer.
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/hevc/hevcdec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 83acf3511f..df186d6194 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -1154,7 +1154,7 @@ static int hls_slice_header(SliceHeader *sh, const HEVCContext *s, GetBitContext
}
ret = get_bits1(gb);
- if (!ret) {
+ if (!ret && get_bits_left(gb) >= 0) {
av_log(s->avctx, AV_LOG_ERROR, "alignment_bit_equal_to_one=0\n");
return AVERROR_INVALIDDATA;
}
--
2.49.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 2+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avcodec/hevc/hevcdec: move the slice header buffer overread check up in the function
2025-05-02 19:28 [FFmpeg-devel] [PATCH 1/2] avcodec/hevc/hevcdec: ensure a bit was read when checking for alignment_bit_equal_to_one James Almer
@ 2025-05-02 19:28 ` James Almer
0 siblings, 0 replies; 2+ messages in thread
From: James Almer @ 2025-05-02 19:28 UTC (permalink / raw)
To: ffmpeg-devel
Abort as soon as we're done reading the slice header instead of running extra checks
that assume slice data may follow.
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/hevc/hevcdec.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index df186d6194..a7a91769fe 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -1160,6 +1160,12 @@ static int hls_slice_header(SliceHeader *sh, const HEVCContext *s, GetBitContext
}
sh->data_offset = align_get_bits(gb) - gb->buffer;
+ if (get_bits_left(gb) < 0) {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Overread slice header by %d bits\n", -get_bits_left(gb));
+ return AVERROR_INVALIDDATA;
+ }
+
// Inferred parameters
sh->slice_qp = 26U + pps->pic_init_qp_minus26 + sh->slice_qp_delta;
if (sh->slice_qp > 51 ||
@@ -1180,12 +1186,6 @@ static int hls_slice_header(SliceHeader *sh, const HEVCContext *s, GetBitContext
return AVERROR_INVALIDDATA;
}
- if (get_bits_left(gb) < 0) {
- av_log(s->avctx, AV_LOG_ERROR,
- "Overread slice header by %d bits\n", -get_bits_left(gb));
- return AVERROR_INVALIDDATA;
- }
-
return 0;
}
--
2.49.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-05-02 19:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-02 19:28 [FFmpeg-devel] [PATCH 1/2] avcodec/hevc/hevcdec: ensure a bit was read when checking for alignment_bit_equal_to_one James Almer
2025-05-02 19:28 ` [FFmpeg-devel] [PATCH 2/2] avcodec/hevc/hevcdec: move the slice header buffer overread check up in the function James Almer
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