Skip to content

Commit 3afdb7e

Browse files
committed
[crash] Handle invalid subtitle bounding boxes
1 parent 46df766 commit 3afdb7e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

vobsub/src/sub.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,15 @@ fn subtitle(raw_data: &[u8], base_time: f64) -> Result<Subtitle> {
353353
alpha = alpha.or(Some(a));
354354
}
355355
ControlCommand::Coordinates(ref c) => {
356+
// Check for weird bounding boxes. Ideally we
357+
// would do this while parsing, but I can't
358+
// figure out how to get nom to do what I want.
359+
// Later on, we assume that all bounding boxes
360+
// have non-negative width and height and we'll
361+
// crash if they don't.
362+
if c.x2 <= c.x1 || c.y2 <= c.y1 {
363+
return Err("invalid bounding box".into());
364+
}
356365
coordinates = coordinates.or(Some(c.clone()));
357366
}
358367
ControlCommand::RleOffsets(r) => {

0 commit comments

Comments
 (0)