Skip to content

[Bug]: MediaFile.ReadFromData throws OverflowException on a malformed Opus file #175

Done

Description

@decriptor

What happens

MediaFile.ReadFromData throws OverflowException out of the read for a malformed 315-byte Opus file:

System.OverflowException: TimeSpan overflowed because the duration is too long.
   at System.TimeSpan.IntervalFromDoubleTicks(Double ticks)
   ... AudioProperties.FromOpus (AudioProperties.cs:123)

MediaFile.Read (path) and MediaFile.Read (stream) read the same bytes successfully. Only the span path throws, which breaks the rule that a read reports failure and does not throw.

Repro (main 88dfbe3)

Base64 of the 315-byte file:

T2dnUwACAAAAAAAAAAChC/sVAAAAAIDB4tgBE09wdXNIZWFkAAIAAAAAAAAAAABPZ2dTAAAAAAAA
AAAAAKEL+xUBAAAAJAu0mwEuT3B1c1RhZ3MeAAAARW5jb2RlZCB3aXRoIEdTdHJlYW1lciBPcHVz
ZW5jAAAAAE9nZ1MABNBcpMZiYiKloQv7FQIAAAAkH1KcAaaHhHLcTK2gTZklUstRBnnE+Lim/YMj
EOeuRyfRYr/M+KU16bIVragluoAyGzGfowI7CMxF9AiskYMCuWzppRw8xafL///CaTFPbkw72vVf
gArmiHwqDhE5EZAbuuZ65wO9xJkWprK55i9gRg/Ey1cBgMjbqpXcoPuGT2dnUwACAAAAAAAAAACl
320HAAAAACIdAiwBE09wdXNIZWFkAQF4AIC7AAAA

MediaFile.ReadFromData (bytes, "a.opus") throws.

Expected

The span path computes the duration the way the stream path does. A duration that does not fit a TimeSpan is treated as unknown or invalid, and is not an exception. All three entry points agree.

Activity

  1. added
    bug
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions