Skip to content

sha256sum implicit stdin opens literal ./- directory before stdin handling #13390

Description

@ChrisRoyse

Reproduction

On Ubuntu resolute with rust-coreutils 0.8.0-0ubuntu3 and /usr/bin/sha256sum provided by coreutils-from-uutils:

mkdir -p /tmp/uutils-sha256sum-dash-repro
cd /tmp/uutils-sha256sum-dash-repro
mkdir -p ./-
printf x | /usr/bin/sha256sum

Observed:

sha256sum: -: Is a directory

Exit status is 1 and stdin is not read.

Control cases from the same cwd:

printf x | /usr/bin/sha256sum /dev/stdin
# 2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881  /dev/stdin

cd /tmp
printf x | /usr/bin/sha256sum
# 2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881  -

Expected

When no file operand is passed, sha256sum should hash standard input and print the - display name regardless of whether the current directory contains a literal ./- path.

Impact

Scripts that run from a directory containing a literal - can get a failed checksum command instead of a stdin digest. If the caller captures the pipeline output without validating command status and digest shape, evidence records can become empty or malformed.

Environment

$ /usr/bin/sha256sum --version | head -1
sha256sum (uutils coreutils) 0.8.0

$ readlink -f /usr/bin/sha256sum
/usr/lib/cargo/bin/coreutils/sha256sum

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