Skip to content

PdfSharp fails to import a jpeg file - MoveToNextHeader moves over EOF #304

@jaku-soft

Description

@jaku-soft

IssueSubmissionTemplate attached

Issue happens during ImageImporterJpeg.ImportImage.
The jpeg file used could be opended by many image viewers and also some online jpeg validation tools found no problems in it.

            // MoveToNextHeader moves to the following positions:
            // 2      Blocklength: 16       Header: 0xFFE0
            // 20     Blocklength: 67       Header: 0xFFDB
            // 89     Blocklength: 67       Header: 0xFFDB
            // 158    Blocklength: 17       Header: 0xFFC0
            // 177    Blocklength: 30       Header: 0xFFC4
            // 209    Blocklength: 47       Header: 0xFFC4
            // 258    Blocklength: 20       Header: 0xFFC4
            // 280    Blocklength: 20       Header: 0xFFC4
            // 302    Blocklength: 12       Header: 0xFFDA
            // 316    Blocklength: 32540    Header: 0xFF00
            // 32858 but FileStream.Length is 29912
            // In TestColorFormatHeader the code tries to read a Word from that last position and failed.

Issue.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions