Skip to content

cksum -c accepts CRC/untagged-CRC checksum lines that GNU 9.4 rejects #1709

Closed

Description

@caomengxuan666

现象(WinuxCmd 1.2.1,origin/main f0cf6b1,C++ cksum)

cksum -c 接受 cksum 自己输出的 CRC 行(3015617425 6 a.txt)和 --untagged 形式并报 OK;GNU coreutils 9.4 的校验器明确不接受 crc/bsd/sysv 格式,报 no properly formatted checksum lines found,rc 1。

复现(PowerShell,产品面)

$d = Join-Path $env:TEMP 'cksum-crc'; New-Item -ItemType Directory -Force $d | Out-Null
Set-Location $d; "hello" | Set-Content -NoNewline a.txt
winuxcmd cksum a.txt > sums.txt
Get-Content sums.txt
winuxcmd cksum -c sums.txt
"rc=$LASTEXITCODE"
winuxcmd cksum -c --untagged sums.txt
"rc=$LASTEXITCODE"

实际:

3015617425 6 a.txt
a.txt: OK
rc=0
a.txt: OK
rc=0

GNU 9.4:

$ cksum a.txt > sums.txt
$ cksum -c sums.txt
cksum: sums.txt: no properly formatted checksum lines found
rc=1
$ cksum -c --untagged sums.txt
cksum: sums.txt: no properly formatted checksum lines found
rc=1

(对照:cksum -a md5 a.txt > m; cksum -c m 两侧都 a.txt: OK rc0;cksum -a crc -c … 两侧都报 --check is not supported with --algorithm={bsd,sysv,crc}。)

影响

“过度接受”方向:依赖 cksum -c 报错来发现格式/内容问题的脚本会被静默当作校验成功。CRC 行本身可以被任意伪造(产品只验证 32 位 CRC,非密码学校验),GNU 选择不支持该组合。

期望

  • -c 的解析器拒绝 crc/bsd/sysv 行(与 -a crc -c 同一判定)。
  • 若产品有意扩展,需在 --help 明确说明并作为兼容扩展记录,而不是静默偏离。

契约表锚点

DOCS/oracle-audit/cksum.md 行 20/21;原始输出 cksum-final.txt 的 17-check-ok、18-check-bad。

Activity

  1. added
    compat-gap
    on Nov 14, 2026
  2. added
    bug
    on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugcompat-gap

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions