Page MenuHomeFreeBSD

libdiff: Detect and recover from file truncation.
ClosedPublic

Authored by des on May 16 2024, 12:26 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, May 20, 1:43 PM
Unknown Object (File)
Mon, May 20, 1:39 AM
Unknown Object (File)
Mon, May 20, 1:38 AM
Unknown Object (File)
Mon, May 20, 1:38 AM
Unknown Object (File)
Sun, May 19, 10:26 PM
Unknown Object (File)
Sun, May 19, 9:56 PM
Unknown Object (File)
Fri, May 17, 7:21 PM
Subscribers

Details

Summary

If a memory-mapped file is truncated before we get to the end, the
atomizer may catch SIGBUS. Detect that, reduce the input length to
what we were actually able to read, and set a flag so the caller can
take further action (e.g. warn the user and / or start over).

Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.May 16 2024, 12:26 PM
markj added inline comments.
contrib/libdiff/lib/diff_atomize_text.c
190–191

Why exactly is this change needed? I can't see the problem with continuing to use pos.

des marked an inline comment as done.Fri, May 17, 5:27 PM
des added inline comments.
contrib/libdiff/lib/diff_atomize_text.c
190–191

pos is volatile, line_start can be cached / optimized.

contrib/libdiff/lib/diff_atomize_text.c
190–191

But then why do we still have .at = pos?

des marked an inline comment as done.Fri, May 17, 8:45 PM
des added inline comments.
contrib/libdiff/lib/diff_atomize_text.c
190–191

Because I didn't spot it...

des marked an inline comment as done.Fri, May 17, 9:00 PM
This revision is now accepted and ready to land.Mon, May 20, 1:20 PM