Page MenuHomeFreeBSD

libdiff: Detect and recover from file truncation.
ClosedPublic

Authored by des on May 16 2024, 12:26 PM.
Tags
None
Referenced Files
F102663264: D45217.diff
Fri, Nov 15, 1:03 PM
Unknown Object (File)
Sat, Nov 9, 2:32 PM
Unknown Object (File)
Tue, Nov 5, 9:00 AM
Unknown Object (File)
Sat, Oct 19, 12:11 AM
Unknown Object (File)
Oct 17 2024, 12:18 AM
Unknown Object (File)
Oct 15 2024, 6:28 AM
Unknown Object (File)
Oct 13 2024, 11:43 PM
Unknown Object (File)
Oct 13 2024, 12:47 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