Page MenuHomeFreeBSD

od(1): Fix skip value handling
ClosedPublic

Authored by delphij on Jun 7 2023, 6:25 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 26, 7:08 PM
Unknown Object (File)
Mon, Oct 21, 10:38 PM
Unknown Object (File)
Oct 14 2024, 4:11 AM
Unknown Object (File)
Oct 11 2024, 1:04 AM
Unknown Object (File)
Oct 10 2024, 8:55 AM
Unknown Object (File)
Sep 28 2024, 8:09 PM
Unknown Object (File)
Sep 23 2024, 5:44 PM
Unknown Object (File)
Sep 20 2024, 3:36 PM
Subscribers
None

Details

Summary

POSIX defines -j as the number of bytes that od(1) should skip over the
concatenated input files. The existing code tries to implement this behavior
by checking if the current address was smaller than the skip value. However,
this is not correct, because we adjust both the skip value and the address
at the same time when we do fseeko (when file is seekable) or getchar (when
file is not seekable).

This commit fixes the problem by expecting the skip value to be zero upon
return of next(). If the condition is not satisfied, a diagnostic message
will be issued.

Reported-by: Mohamed Akram <mohd.akram@outlook.com>
PR: 271832
MFC-after: 2 weeks

Test Plan

od -j 5 shall issue error for a 4 byte long file, hexdump -s 5 behavior shall remain

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 51939
Build 48830: arc lint + arc unit

Event Timeline

delphij created this revision.
This revision is now accepted and ready to land.Jun 7 2023, 1:53 PM
This revision was automatically updated to reflect the committed changes.