Skip to content

MachOFile link-edit readers force-unwrap missing __LINKEDIT data #323

Description

@p-x9

These initializers force-unwrap _fileSliceForLinkEditData / _readLinkEditData, which return nil when the range is not inside __LINKEDIT or the file:

Reader Location
Symbols64 / Symbols MachOFile+Symbols.swift:76, :81, :222, :227
ExportTrie MachOFile+ExportTrie.swift:119
FunctionStarts MachOFile+FunctionStarts.swift:37

Reproduce

  • symbols64 on any MH_OBJECT (clang -c): relocatable objects have LC_SYMTAB but no __LINKEDIT segment.
  • A truncated binary, or a symoff / stroff / dataoff pointing past EOF.

Suggestion

Return nil from symbols64 / symbols32 / exportTrie / functionStarts when the slice cannot be created. For objects, fall back to reading symoff / stroff relative to the file (they are plain file offsets there).

Activity

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions