Page MenuHomeFreeBSD

md5: Encode non-printable filenames
ClosedPublic

Authored by des on Fri, Apr 24, 11:42 AM.
Tags
None
Referenced Files
F154882844: D56615.diff
Wed, Apr 29, 6:25 PM
F154725262: D56615.diff
Wed, Apr 29, 7:57 AM
Unknown Object (File)
Tue, Apr 28, 9:46 AM
Unknown Object (File)
Tue, Apr 28, 8:53 AM
Unknown Object (File)
Tue, Apr 28, 8:53 AM
Unknown Object (File)
Mon, Apr 27, 7:02 PM
Unknown Object (File)
Mon, Apr 27, 6:53 PM
Unknown Object (File)
Mon, Apr 27, 2:04 PM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 72515
Build 69398: arc lint + arc unit

Event Timeline

des requested review of this revision.Fri, Apr 24, 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.

647

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.