Fixed a crash in the PSI decoder when a packet with an invalid PSI offset is received.
Some checks failed
🚀 Pack skyscraper8 / make-zip (push) Failing after 35s

This commit is contained in:
feyris-tan 2026-05-16 20:50:44 +02:00
parent a58fb93599
commit 67bc722c66

View File

@ -28,10 +28,7 @@ namespace skyscraper5.Mpeg2
{ {
Span<byte> span = packet.GetPayload(); Span<byte> span = packet.GetPayload();
int automataIterations = 0; int automataIterations = 0;
if (packet.PID == 0x0881)
;
while(span.Length > 0) while(span.Length > 0)
{ {
switch(state) switch(state)
@ -45,6 +42,12 @@ namespace skyscraper5.Mpeg2
} }
byte startOffset = span[0]; byte startOffset = span[0];
span = span.Slice(1); 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); span = span.Slice(startOffset);
state = 1; state = 1;
break; break;