(security) Enforce frame limit in VideoMediaIO (#38636)

Signed-off-by: jperezde <jperezde@redhat.com>
This commit is contained in:
Juan Pérez de Algaba
2026-04-01 10:23:45 +00:00
committed by GitHub
parent f9f6a9097a
commit 58ee614221
2 changed files with 69 additions and 10 deletions
+8 -1
View File
@@ -80,8 +80,15 @@ class VideoMediaIO(MediaIO[tuple[npt.NDArray, dict[str, Any]]]):
"image/jpeg",
)
if self.num_frames > 0:
frame_parts = data.split(",", self.num_frames)[: self.num_frames]
elif self.num_frames == 0:
raise ValueError("num_frames must be greater than 0 or -1")
else:
frame_parts = data.split(",")
frames = np.stack(
[np.asarray(load_frame(frame_data)) for frame_data in data.split(",")]
[np.asarray(load_frame(frame_data)) for frame_data in frame_parts]
)
total = int(frames.shape[0])
fps = float(self.kwargs.get("fps", 1))