Skip to content

Commit 6e5565c

Browse files
Gnurourosetta-jpn
authored andcommitted
decoder/stateless/h264: perform index range check
We might get an out-of-bounds index with an invalid stream - check that the index is valid before addressing. This issue has been revealed by fuzzing.
1 parent 9979b2b commit 6e5565c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/decoder/stateless/h264.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,9 @@ where
607607
.find_short_term_with_pic_num(pic_num_lx)
608608
.with_context(|| format!("No ShortTerm reference found with pic_num {}", pic_num_lx))?;
609609

610+
if *ref_idx_lx >= ref_pic_list_x.len() {
611+
anyhow::bail!("invalid ref_idx_lx index");
612+
}
610613
ref_pic_list_x.insert(*ref_idx_lx, handle);
611614
*ref_idx_lx += 1;
612615

@@ -651,6 +654,9 @@ where
651654
)
652655
})?;
653656

657+
if *ref_idx_lx >= ref_pic_list_x.len() {
658+
anyhow::bail!("invalid ref_idx_lx index");
659+
}
654660
ref_pic_list_x.insert(*ref_idx_lx, handle);
655661
*ref_idx_lx += 1;
656662

0 commit comments

Comments
 (0)