Page MenuHomeFreeBSD

md5: Encode non-printable filenames
ClosedPublic

Authored by des on Apr 24 2026, 11:42 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 22, 2:16 AM
Unknown Object (File)
Tue, May 19, 11:04 PM
Unknown Object (File)
Sun, May 17, 8:34 PM
Unknown Object (File)
Sun, May 17, 8:26 PM
Unknown Object (File)
Thu, May 14, 12:48 PM
Unknown Object (File)
Thu, May 14, 3:46 AM
Unknown Object (File)
Thu, May 14, 3:44 AM
Unknown Object (File)
Thu, May 14, 3:43 AM
Subscribers

Details

Summary

Encode filenames in the VIS_CSTYLE | VIS_OCTAL style regardless of
output mode. When reading filenames from a checksum file, attempt to
decode them, and use the decoded name unless the decoded name does not
exist but the undecoded one does.

This breaks compatibility with GNU coreutils, which unfortunately uses
a non-reversible encoding when outputting filenames containing
non-printable characters.

While here, drop a sentence about preimage attacks against MD5 and SHA1
from the manual page, as I no longer trust it to be true.

MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.Apr 24 2026, 11:42 AM
bcr added a subscriber: bcr.

OK for the man page part of the change.

This revision is now accepted and ready to land.Sat, Apr 25, 8:25 AM
sbin/md5/md5.c
402

Why _GLOB and _SHELL? The concern is related to terminal escape sequences. I'd think that VIS_SAFE (and VIS_NL) is sufficient.

656

Missing newline after variable declarations.

des marked an inline comment as done.Mon, Apr 27, 4:56 PM
des added inline comments.
sbin/md5/md5.c
402

Because I'm also concerned about scripts parsing the output and being careless with the result...

sbin/md5/md5.c
402

Ok, but then we should explicitly include VIS_SAFE in the list too. ANSI escape sequences get mangled as a consequence of embedding '[', covered by VIS_GLOB, but we probably shouldn't rely on that.

sbin/md5/md5.c
402

No, we should most definitely not add VIS_SAFE. It prevents the backspace, bell, and carriage return characters from being encoded.

sbin/md5/md5.c
402

Why would you expect to find those in a filename?

sbin/md5/md5.c
402

I wouldn't, but that's the whole point of this change.

sbin/md5/md5.c
402

Right, so why not escape those characters?

sbin/md5/md5.c
402

Exactly. Right now they are being escaped. If we add VIS_SAFE they won't be.

markj added inline comments.
sbin/md5/md5.c
402

Ok I finally get it, I misunderstood what VIS_SAFE actually does.

sbin/md5/md5.c
402

I'll submit a patch for the manual page.

This revision was automatically updated to reflect the committed changes.