[FFmpeg-cvslog] avcodec/h264: Be more strict on rejecting pps/sps changes
Michael Niedermayer
git at videolan.org
Thu Feb 12 18:11:58 CET 2015
ffmpeg | branch: release/2.5 | Michael Niedermayer <michaelni at gmx.at> | Fri Feb 6 15:09:54 2015 +0100| [756d85dc144aaf124e8f37cf878d6d9237f29f0e] | committer: Michael Niedermayer
avcodec/h264: Be more strict on rejecting pps/sps changes
Fixes race condition
Fixes: signal_sigsegv_1472ac3_468_cov_2915641226_CABACI3_Sony_B.jsv
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 6fafc62b0bd0e206deb77a7aabbf3a370ad80789)
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=756d85dc144aaf124e8f37cf878d6d9237f29f0e
---
libavcodec/h264_slice.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 53f61ca..d5e85c2 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1305,6 +1305,8 @@ int ff_h264_decode_slice_header(H264Context *h, H264Context *h0)
int must_reinit;
int needs_reinit = 0;
int field_pic_flag, bottom_field_flag;
+ int first_slice = h == h0 && !h0->current_slice;
+ PPS *pps;
h->qpel_put = h->h264qpel.put_h264_qpel_pixels_tab;
h->qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab;
@@ -1378,18 +1380,27 @@ int ff_h264_decode_slice_header(H264Context *h, H264Context *h0)
h0->au_pps_id, pps_id);
return AVERROR_INVALIDDATA;
}
- h->pps = *h0->pps_buffers[pps_id];
- if (!h0->sps_buffers[h->pps.sps_id]) {
+ pps = h0->pps_buffers[pps_id];
+
+ if (!h0->sps_buffers[pps->sps_id]) {
av_log(h->avctx, AV_LOG_ERROR,
"non-existing SPS %u referenced\n",
h->pps.sps_id);
return AVERROR_INVALIDDATA;
}
+ if (first_slice)
+ h->pps = *h0->pps_buffers[pps_id];
+
+ if (pps->sps_id != h->sps.sps_id ||
+ pps->sps_id != h->current_sps_id ||
+ h0->sps_buffers[pps->sps_id]->new) {
- if (h->pps.sps_id != h->sps.sps_id ||
- h->pps.sps_id != h->current_sps_id ||
- h0->sps_buffers[h->pps.sps_id]->new) {
+ if (!first_slice) {
+ av_log(h->avctx, AV_LOG_ERROR,
+ "SPS changed in the middle of the frame\n");
+ return AVERROR_INVALIDDATA;
+ }
h->sps = *h0->sps_buffers[h->pps.sps_id];
More information about the ffmpeg-cvslog
mailing list