Page MenuHomeFreeBSD

libdiff: Detect and recover from file truncation.
ClosedPublic

Authored by des on May 16 2024, 12:26 PM.
Tags
None
Referenced Files
F86717633: D45217.diff
Mon, Jun 24, 12:17 PM
Unknown Object (File)
May 20 2024, 1:43 PM
Unknown Object (File)
May 20 2024, 1:39 AM
Unknown Object (File)
May 20 2024, 1:38 AM
Unknown Object (File)
May 20 2024, 1:38 AM
Unknown Object (File)
May 19 2024, 10:26 PM
Unknown Object (File)
May 19 2024, 9:56 PM
Unknown Object (File)
May 17 2024, 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.May 17 2024, 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.May 17 2024, 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.May 17 2024, 9:00 PM
This revision is now accepted and ready to land.May 20 2024, 1:20 PM