Bug 167977 - [smbfs] mount_smbfs results are differ when utf-8 or UTF-8 local encoding's name is used
Summary: [smbfs] mount_smbfs results are differ when utf-8 or UTF-8 local encoding's n...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 9.0-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: John Baldwin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-16 20:40 UTC by Alexey Kovalenko
Modified: 2014-12-24 17:02 UTC (History)
4 users (show)

See Also:


Attachments
kiconv_case.patch (1.10 KB, patch)
2014-06-05 13:52 UTC, John Baldwin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Kovalenko 2012-05-16 20:40:01 UTC
When .nsmbrc contains

[default]
charsets=UTF-8:cp866

remote (windows 2000) filenames with "№" character are displayed ok
( "123№123" ), but when 

[default]
charsets=utf-8:cp866

(note lo-case) filenames are garbaged ( same name as above wiil be "123?"). 

Thereis no SMBFS nor NETSMB options in kernel config
options LIBICONV is.

"№" is 3-byte in UTF-8. XLAT16_ACCEPT_3BYTE_CHR isn't used at build time.

ldserver# smbutil -v lc
SMB connections:
VC: \\SSS\USER
(root:wheel) 711
    state:    Session active
    flags:    0x0428 <private|encpwd>
    usecount: 1
    dialect:  6 (NT LM 0.12, Windows for Workgroups 3.1a, NT LANMAN 1.0)
    smode:    3
    caps:     0xf3fd <SMB_CAP_RAW_MODE|SMB_CAP_UNICODE|SMB_CAP_LARGE_FILES|SMB_CAP_NT_SMBS|SMB_CAP_NT_FIND>
    maxmux:   50
    maxvcs:   1
    Share:    D$(root:wheel) 711
        flags:    0x0004 <>
        usecount: 1

How-To-Repeat: mount remote smb share, look at files with "&#8470;" in name
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2012-05-16 21:22:26 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-fs

Over to maintainer(s).
Comment 2 buganini 2012-05-16 22:08:14 UTC
How about change line 105 and 107 in /usr/src/sys/libkern/iconv_ucs.c
from strcmp to strcasecmp ?

Regards,
Buganini
Comment 3 Semen Soldatov 2014-06-05 12:15:25 UTC
(In reply to buganini from comment #2)
> How about change line 105 and 107 in /usr/src/sys/libkern/iconv_ucs.c
> from strcmp to strcasecmp ?
> 
> Regards,
> Buganini

with strcasecmp all works ok.
Comment 4 John Baldwin freebsd_committer freebsd_triage 2014-06-05 13:52:46 UTC
Created attachment 143407 [details]
kiconv_case.patch

I think this is correct as iconv(1) accepts case-insensitive encoding names.  I think there is one other place that should also use strcasecmp() (when looking to see if we already have an existing encoding mapping that can be reused).
Comment 5 Semen Soldatov 2014-06-06 04:38:31 UTC
(In reply to John Baldwin from comment #4)
> Created attachment 143407 [details]
> kiconv_case.patch
> 
> I think this is correct as iconv(1) accepts case-insensitive encoding names.
> I think there is one other place that should also use strcasecmp() (when
> looking to see if we already have an existing encoding mapping that can be
> reused).

Thx, i set strcasecmp in iconv_ucs.c and utf8 encoding map works ok. if i set koi8-r without patch strcasecmp in iconv.c then filename broken. your patch work fine.
Comment 6 commit-hook freebsd_committer freebsd_triage 2014-06-09 19:28:00 UTC
A commit references this bug:

Author: jhb
Date: Mon Jun  9 19:27:48 UTC 2014
New revision: 267291
URL: http://svnweb.freebsd.org/changeset/base/267291

Log:
  Use strcasecmp() instead of strcmp() when checking user-supplied encoding
  names so that encoding names are treated as case-insensitive.  This allows
  the use of 'utf-8' instead of 'UTF-8' for example and matches the behavior
  of iconv(1).

  PR:		167977
  Submitted by:	buganini@gmail.com
  MFC after:	1 week

Changes:
  head/sys/libkern/iconv.c
  head/sys/libkern/iconv_ucs.c
Comment 7 John Baldwin freebsd_committer freebsd_triage 2014-06-09 19:29:22 UTC
Committed to HEAD, thanks!
Comment 8 commit-hook freebsd_committer freebsd_triage 2014-06-27 20:40:05 UTC
A commit references this bug:

Author: jhb
Date: Fri Jun 27 20:39:46 UTC 2014
New revision: 267980
URL: http://svnweb.freebsd.org/changeset/base/267980

Log:
  MFC 267291:
  Use strcasecmp() instead of strcmp() when checking user-supplied encoding
  names so that encoding names are treated as case-insensitive.  This allows
  the use of 'utf-8' instead of 'UTF-8' for example and matches the behavior
  of iconv(1).

  PR:		167977

Changes:
_U  stable/10/
  stable/10/sys/libkern/iconv.c
  stable/10/sys/libkern/iconv_ucs.c
_U  stable/9/sys/
  stable/9/sys/libkern/iconv.c
  stable/9/sys/libkern/iconv_ucs.c