From 67bc722c663e86e34a6f5e51e94f65d9b23eb415 Mon Sep 17 00:00:00 2001 From: feyris-tan <4116042+feyris-tan@users.noreply.github.com> Date: Sat, 16 May 2026 20:50:44 +0200 Subject: [PATCH] Fixed a crash in the PSI decoder when a packet with an invalid PSI offset is received. --- skyscraper8/Mpeg2/PsiDecoder.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/skyscraper8/Mpeg2/PsiDecoder.cs b/skyscraper8/Mpeg2/PsiDecoder.cs index 55760cd..64762c8 100644 --- a/skyscraper8/Mpeg2/PsiDecoder.cs +++ b/skyscraper8/Mpeg2/PsiDecoder.cs @@ -28,10 +28,7 @@ namespace skyscraper5.Mpeg2 { Span span = packet.GetPayload(); int automataIterations = 0; - - if (packet.PID == 0x0881) - ; - + while(span.Length > 0) { switch(state) @@ -45,6 +42,12 @@ namespace skyscraper5.Mpeg2 } byte startOffset = span[0]; span = span.Slice(1); + if (startOffset > span.Length) + { + logger.WarnFormat("An MPEG-2 section with an invalid starting offsett was found. It will be skipped."); + state = 0; + return; + } span = span.Slice(startOffset); state = 1; break;