Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

od: zero-fill input to required byte length #154

Merged
merged 1 commit into from
Apr 29, 2023

Commits on Apr 14, 2023

  1. zero-fill input to required byte length

    * I noticed that when the number of input bytes is odd, the output of od -x is incorrect
    * This was because unpack('S', $data) returns nothing if $data is 1 byte
    * Standard od zero-fills the 16 bit number
    * The do-remainder-bytes logic is incorrect (tangled web of pack, unpack and substr)
    * float() and long() require input to be zero-filled 32-bits
    * udecimal(), decimal(), octal2() and hex() require input to be zero-filled 16-bits
    * Patch tested on amd64 against GNU od
    
    Original output which uncovered this:
    $ perl hexdump test
    00000000  c6 f3                                             |..|
    $ od -j 1 -x test # gnu od
    0000001 00f3
    0000002
    $ perl od -j 1 -x test
    00000001 0001
    00000002
    
    Also without -j:
    $ xxd in2 
    00000000: d8ab 7a                                  ..z
    $ perl od -x in2
    00000000 abd8 0000
    00000003
    mknos committed Apr 14, 2023
    Configuration menu
    Copy the full SHA
    2fcf6b6 View commit details
    Browse the repository at this point in the history