Skip to content

od: -w produces incorrect line widths at 8192-byte boundaries #17024

In review

Description

@tomoya-fukami

With -w20, od splits the last 20-byte line of an 8200-byte input into two lines at offset 8192 (0x2000). GNU od prints those 20 bytes on one line.

I reproduced this on Ubuntu 26.04.1 LTS with uutils 0.13.0 built from commit 2a072db2938ee1b697459886ffd171a0f5fd064c and with Ubuntu’s installed uutils 0.10.0. I compared the output with Ubuntu’s gnuod (GNU coreutils 9.7).

Steps to reproduce

Run these commands from the repository root. sed shows the output from line 407 onward, including three full-width lines before the split.

cargo build --locked -p uu_od --bin od

for cmd in ./target/debug/od /usr/bin/gnuod; do
    printf '%s\n' "$cmd"
    LC_ALL=C "$cmd" -v -Ax -t x1 -w20 -N8200 /dev/zero | sed -n '407,$p'
done

Actual output (uutils)

The last 20 bytes appear on two lines, with 12 bytes at 001ff4 and 8 bytes at 002000.

001fb8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
001fcc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
001fe0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
001ff4 00 00 00 00 00 00 00 00 00 00 00 00
002000 00 00 00 00 00 00 00 00
002008

Expected output (GNU od)

All 8200 bytes should fit into 410 data lines of 20 bytes each. The last data line starts at 001ff4 and spans the buffer boundary.

001fb8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
001fcc 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
001fe0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
001ff4 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
002008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions