From: Hin-Tak Leung Subject: Re: [PATCH 1/3] hfsplus: fixes worst-case unicode to char conversion of file names and attributes Date: Wed, 23 Apr 2014 02:43:00 +0100 (BST) Message-ID: <1398217380.39515.YahooMailBasic@web172302.mail.ir2.yahoo.com> Reply-To: htl10@users.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-fsdevel@vger.kernel.org, slava@dubeyko.com, viro@zeniv.linux.org.uk, hch@infradead.org, sougata@tuxera.com To: akpm@linux-foundation.org Return-path: Received: from nm9-vm2.bullet.mail.ir2.yahoo.com ([212.82.96.145]:43609 "EHLO nm9-vm2.bullet.mail.ir2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750927AbaDWBnD convert rfc822-to-8bit (ORCPT ); Tue, 22 Apr 2014 21:43:03 -0400 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: ------------------------------ On Tue, Apr 22, 2014 9:28 PM BST Andrew Morton wrote: >On Thu, 17 Apr 2014 20:30:20 +0100 Hin-Tak Leung wrote: > >> From: Hin-Tak Leung >>=20 >> The HFS Plus Volume Format specification (TN1150) states that >> file names are stored internally as a maximum of 255 unicode >> characters, as defined by The Unicode Standard, Version 2.0 >> [Unicode, Inc. ISBN 0-201-48345-9]. File names are converted by >> the NLS system on Linux before presented to the user. >>=20 >> 255 CJK characters converts to UTF-8 with 1 unicode character >> to up to 3 bytes, and to GB18030 with 1 unicode character to >> up to 4 bytes. Thus, trying in a UTF-8 locale to list files >> with names of more than 85 CJK characters results in: >>=20 >>=A0 =A0=A0=A0$ ls /mnt >>=A0 =A0=A0=A0ls: reading directory /mnt: File name too long >>=20 >> The receiving buffer to hfsplus_uni2asc() needs to be 255 x >> NLS_MAX_CHARSET_SIZE bytes, not 255 bytes as the code has always bee= n. >>=20 >> Similar consideration applies to attributes, which are stored >> internally as a maximum of 127 UTF-16BE units. See XNU source for >> an up-to-date reference on attributes. >>=20 >> Strictly speaking, the maximum value of NLS_MAX_CHARSET_SIZE =3D 6 >> is not attainable in the case of conversion to UTF-8, as going >> beyond 3 bytes requires the use of surrogate pairs, i.e. consuming >> two input units. >>=20 >> Thanks Anton Altaparmakov for reviewing an earlier version of this >> change. >>=20 >> This patch fixes all callers of hfsplus_uni2asc(), and also enables >> the use of long non-English file names in HFS+. The getting and >> setting, and general usage of long non-English attributes >> requires further forthcoming work, in the following patches of this >> series. >>=20 > >fs/hfsplus/xattr.c: In function 'hfsplus_listxattr': >fs/hfsplus/xattr.c:673: error: label 'out' used but not defined > >--- a/fs/hfsplus/xattr.c~hfsplus-fixes-worst-case-unicode-to-char-conv= ersion-of-file-names-and-attributes-fix >+++ a/fs/hfsplus/xattr.c >@@ -726,6 +726,7 @@ ssize_t hfsplus_listxattr(struct dentry >=20 > end_listxattr: > =A0=A0=A0 kfree(strbuf); >+out: > =A0=A0=A0 hfs_find_exit(&fd); > =A0=A0=A0 return res; > } > >But obviously the patches you sent were not the patches you tested.=20 >What happened here? > Hi Andrew, Am terribly sorry - my fault of using/working/testing under one kernel = (3.13.9), then cherry-picking onto Linus' HEAD and collapsing there. A couple of = small changes got dropped/messed up. There is the missing headers (#include ) in xattr*.c you spotted in the other mail; the= above is meant to be corrected by re-using the label nearby (as kfree(null) i= s okay...), rather than adding a new label. diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c index 3ddf50c..2a38647 100644 --- a/fs/hfsplus/xattr.c +++ b/fs/hfsplus/xattr.c @@ -670,7 +670,7 @@ ssize_t hfsplus_listxattr(struct dentry *dentry, ch= ar *buffer, size_t size) XATTR_MAC_OSX_PREFIX_LEN + 1, GFP_KERNEL); if (!strbuf) { res =3D -ENOMEM; - goto out; + goto end_listxattr; } =20 err =3D hfsplus_find_attr(inode->i_sb, inode->i_ino, NULL, &fd)= ; Do you want me to re-submit? I checked the diff of the two branches, it is just these two issues. Really sorry about that. Hin-Tak -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html