Skip to content

mmap invalid file contents #24736

@trufae

Description

@trufae

we may be switching to stdio by default because mmap is known to be flacky way to access file contents, and also adding guardrails just make things slower without really fixing the toctou problem, but anyway, here's one testcase that shows how stdio works well but mmap misbehaves and both plugins must behave the same way:

$ echo hello world | tee a
hello world
$ r2 -qwc'wtf a $$@ 5;px 32' a
INFO: Dumped 5 bytes from 0x00000005 into a
- offset -   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0123456789ABCDEF
0x00000000  2077 6f72 6c00 0000 0000 0000 ffff ffff   worl...........
0x00000010  ffff ffff ffff ffff ffff ffff ffff ffff  ................

$ echo hello world | tee a
hello world
$ r2 -qwc'wtf a $$@ 5;px 32' stdio://a
INFO: Dumped 5 bytes from 0x00000005 into a
- offset -   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0123456789ABCDEF
0x00000000  2077 6f72 6cff ffff ffff ffff ffff ffff   worl...........
0x00000010  ffff ffff ffff ffff ffff ffff ffff ffff  ................
$ 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions