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)
Mon, May 6, 5:51 AM
Unknown Object (File)
Mar 14 2024, 2:55 AM
Unknown Object (File)
Feb 27 2024, 9:21 AM
Unknown Object (File)
Feb 10 2024, 10:24 PM
Unknown Object (File)
Jan 7 2024, 4:55 PM
Unknown Object (File)
Dec 26 2023, 2:52 AM
Unknown Object (File)
Dec 12 2023, 7:04 AM
Unknown Object (File)
Oct 30 2023, 2:12 AM
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 Not Applicable
Unit
Tests Not Applicable

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.