From owner-freebsd-bugs@freebsd.org Sun Apr 29 18:45:44 2018 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A3B4EFB4FEC for ; Sun, 29 Apr 2018 18:45:44 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 3B7F573828 for ; Sun, 29 Apr 2018 18:45:44 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id ED251FB4FEB; Sun, 29 Apr 2018 18:45:43 +0000 (UTC) Delivered-To: bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C92F4FB4FEA for ; Sun, 29 Apr 2018 18:45:43 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org [IPv6:2001:1900:2254:206a::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.ysv.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6440173827 for ; Sun, 29 Apr 2018 18:45:43 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id A06611DE54 for ; Sun, 29 Apr 2018 18:45:42 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id w3TIjgen002761 for ; Sun, 29 Apr 2018 18:45:42 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id w3TIjgrG002759 for bugs@FreeBSD.org; Sun, 29 Apr 2018 18:45:42 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 111843] [msdosfs] Long Names of files are incorrectly created on msdosfs Date: Sun, 29 Apr 2018 18:45:40 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 6.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: damjan.jov@gmail.com X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: Normal X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Apr 2018 18:45:44 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D111843 Damjan Jovanovic changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |damjan.jov@gmail.com --- Comment #3 from Damjan Jovanovic --- Still happens on CURRENT. Can be reproduced with any file where, for an integer N > 0, the filename begins with 13*N valid characters, the last of those not being a space or d= ot, and extra spaces and/or dots follow those characters. For example: $ touch "1234567890123 " $ ls 123456~1 Why? In sys/fs/msdosfs/msdosfs_lookup.c, ddep->de_fndcnt gets set in the msdosfs_lookup_() function, and it's supposed to count the number of LFN entries we will need to store the long filename. This is obtained from winSlotCnt() which trims trailing spaces and dots with winLenFixup(), and divides the resulting length by WIN_CHARS (13), which is the maximum number= of chars in an LFN entry. createde() in sys/fs/msdosfs/msdosfs_lookup.c generates the long file name = from this, by calling unix2winfn() ddep->de_fndcnt times, each one generating one LFN entry for that consecutive non-overlapping 13 character substring of the long filename. The bug is in this unix2winfn() function in sys/fs/msdosfs/msdosfs_conv.c. = The function trims trailing spaces and/or dots, and then tries to write up to 1= 3 of the remaining characters into the LFN entry. The last LFN entry must have WIN_LAST (0x40) OR-ed into its sequence number. If the filename ends before= all 13 characters are populated, WIN_LAST is set. But if the filename is an exa= ct multiple of 13 characters, the code relies on the original string to termin= ate in "\0" in order to set WIN_LAST: if (*un =3D=3D '\0') end =3D WIN_LAST; The problem is that if the string ends in spaces and/or dots, it doesn't en= d in "\0" yet, so that test fails and WIN_LAST isn't set, producing a corrupt lo= ng filename. With the long filename corrupted, "ls" only shows the short name. --=20 You are receiving this mail because: You are the assignee for the bug.=