Skip to content

Crash (OOM / std::bad_alloc / abort) when opening RAW files without resolution in filename or with invalid parameters #661

Description

@for13to1

Describe the bug

When trying to open a RAW video file that has no resolution information in the filename (e.g. 1.raw), YUView crashes instantly. The crash happens due to either:

  1. QByteArray::resize assertion failure / abort when the calculated frame byte size (nrBytes) overflows to a negative integer.
  2. An uncaught std::bad_alloc exception when trying to allocate a massive amount of memory for uninitialized or invalid resolution parameters.

This issue is particularly reproducible on Windows, but the underlying safety loopholes exist across all platforms.

Steps to reproduce

  1. Start YUView.
  2. Attempt to open a RAW file named 1.raw (which does not contain resolution indicators like _1920x1080_).
  3. The application aborts or crashes immediately.

Analysis of the root cause

  1. No bounds check on dimensions: Size::isValid() only checks width > 0 && height > 0 but has no upper boundary check. Thus, huge or corrupted sizes parsed or guessed from files are accepted.
  2. Integer Overflow: In PixelFormatRGB::getBytesPerFrame, multiplying large dimensions can overflow a 32-bit signed int to a negative value.
  3. No negative check in FileSource: In FileSource::readBytes, there is no check for nrBytes <= 0. Passing a negative size to QByteArray::resize triggers an abort in Qt or casts it to a huge size_t allocation.
  4. Uncaught Exceptions: Functions like playlistItemRawFile::loadRawData and videoHandler::loadFrame convert/read data without catching std::bad_alloc, causing unhandled exceptions to crash the application.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions