[Bug 265746] Can create/cd directory with ^M at end of name with "mkdir", but can't delete it with "rm"

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 09 Aug 2022 21:40:54 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265746

            Bug ID: 265746
           Summary: Can create/cd directory with ^M at end of name with
                    "mkdir", but can't delete it with "rm"
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: nc@FreeBSD.org

Created attachment 235817
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=235817&action=edit
Bad DOS-formatted "shar" file which makes a directory ending with ^M

When I was importing a "new port" with a DOS-formatted "shar" file, mkdir
created a directory with a "^M" at the end of the filename, and I can cd into
that directory.

However, I can't remove a directory ending in "^M" with rm.

This bug affects at least rm, if not multiple base system utilities.

It may also affect OpenZFS, but I'm not sure.

I am using ZFS.

Example runtime:

# sh ~/bad_shar
# cd "jbxvt^M"
# pwd
/usr/ports/x11/jbxvt
# cd ..
# rm -r "jbxvt^M/"
/: No such file or directory
#

Shar file attached.

-- 
You are receiving this mail because:
You are the assignee for the bug.