Bug 494 - cannot access share name include '\' in unix charset
Summary: cannot access share name include '\' in unix charset
Status: CLOSED FIXED
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: Extended Characters (show other bugs)
Version: 3.0.0preX
Hardware: All All
: P3 normal
Target Milestone: none
Assignee: Jeremy Allison
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-09-22 20:47 UTC by TAKAHASHI Motonobu
Modified: 2005-08-24 10:28 UTC (History)
1 user (show)

See Also:


Attachments
a patch which enables accessing a share with 0x5c code (1.26 KB, patch)
2004-01-18 23:38 UTC, Shiro Yamada
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description TAKAHASHI Motonobu 2003-09-22 20:47:01 UTC
if we have a share whose name includes '\' (0x5c) 
in its name in 'unix charset' encoding.
For example

[global]
  unix charset = CP932
  dos charset = CP932

[--]  * -- means a 2byte string {0x83, 0x5c}

Browsing works well but cannot access.
This is a part of level 3 log when access \\server\-- (-- means 0x83, 0x5c)

[2003/09/23 07:19:35, 3] smbd/error.c:error_packet(113)
  error packet at smbd/reply.c(274) cmd=117 (SMBtconX) 
NT_STATUS_BAD_NETWORK_NAME
[2003/09/23 07:19:35, 3] smbd/process.c:process_smb(890)
  Transaction 52 of length 92
[2003/09/23 07:19:35, 3] smbd/process.c:switch_message(685)
  switch message SMBtconX (pid 10564)
[2003/09/23 07:19:35, 3] smbd/sec_ctx.c:set_sec_ctx(288)
  setting sec ctx (0, 0) - sec_ctx_stack_ndx = 0
[2003/09/23 07:19:35, 3] lib/charcnv.c:convert_string_allocate(444)
  convert_string_allocate: Conversion error: Illegal multibyte sequence(<83>/)
(snip)
  convert_string_allocate: Conversion error: Illegal multibyte sequence(<83>/)
[2003/09/23 07:19:35, 3] lib/charcnv.c:convert_string_allocate(444)
  convert_string_allocate: Conversion error: Illegal multibyte sequence(<83>/)
[2003/09/23 07:19:35, 3] smbd/service.c:find_service(143)
  checking for home directory <83>/ gave (NULL)
[2003/09/23 07:19:35, 3] smbd/service.c:find_service(157)
  checking whether <83>/ is a valid printer name...
[2003/09/23 07:19:35, 3] lib/charcnv.c:convert_string_allocate(444)
  convert_string_allocate: Conversion error: Illegal multibyte sequence(<83>/)
[2003/09/23 07:19:35, 3] lib/charcnv.c:convert_string_allocate(444)
  convert_string_allocate: Conversion error: Illegal multibyte sequence(<83>/)
[2003/09/23 07:19:35, 3] smbd/service.c:find_service(169)
  <83>/ is not a valid printer name
[2003/09/23 07:19:35, 3] smbd/service.c:find_service(211)
  find_service() failed to find service <83>/
[2003/09/23 07:19:35, 3] lib/charcnv.c:convert_string_allocate(444)
  convert_string_allocate: Conversion error: Illegal multibyte sequence(<83>/)
[2003/09/23 07:19:35, 3] lib/charcnv.c:convert_string_allocate(444)
  convert_string_allocate: Conversion error: Illegal multibyte sequence(<83>/)
[2003/09/23 07:19:35, 0] smbd/service.c:make_connection(848)
  monyo31 (192.168.230.1) couldn't find service <83>/
[2003/09/23 07:19:35, 3] smbd/error.c:error_packet(94)
  error string = Invalid or incomplete multibyte or wide character
[2003/09/23 07:19:35, 3] smbd/error.c:error_packet(113)
  error packet at smbd/reply.c(274) cmd=117 (SMBtconX) 
NT_STATUS_BAD_NETWORK_NAME
Comment 1 Shiro Yamada 2004-01-18 23:20:11 UTC
If a share name is defined using a MB char with '0x5D' in its second
byte, where '0x5D' is equivalent of '\' in ascii code, then although
the share name is retrievable by SMB clients, they cannot access it,
returning the error NT_STATUS_BAD_NETWORK_NAME.

The source of this problem is that smbd replaces '\' with '/' by
all_string_sub() in find_service() function. Because all_string_sub()
handles strings in single byte, the second byte of MB char is 
wrongly identified as '\' and hence converted '/'. Since the second
byte of MB char has changed, Samba fails to retrieve the share
specified as the argument for searching the share is no longer valid.

smbd/service.c
---
int find_service(fstring service)
{
   int iService;

   all_string_sub(service,"\\","/",0);

   iService = lp_servicenumber(service);

   ...
}
---
Comment 2 Shiro Yamada 2004-01-18 23:38:38 UTC
Created attachment 363 [details]
a patch which enables accessing a share with 0x5c code

This patch enables accessing a share with '0x5c' code, by first converting its
name
from unix charset to UCS2, followed by replacing '\' with '/' under UCS2 format

and then convert the end product back to unix charset. It is an expensive
operation
but probably the only solution for this bug under current implementation.
Comment 3 Gerald (Jerry) Carter (dead mail address) 2004-03-04 09:38:58 UTC
Jeremy,

Is this still an issue?  Can you take a look?  Thanks.
Comment 4 Jeremy Allison 2004-03-08 17:45:37 UTC
Ok, I think I've just fixed this by changing occurrences of strstr() to a
new implementation strstr_m(). Please check this out and let me know if it
is now fixed in SAMBA_3_0 CVS (it should be).
Jeremy.
Comment 5 Gerald (Jerry) Carter (dead mail address) 2004-03-17 05:44:43 UTC
jeremy says fixed.  please let us know if this is 
not the case.
Comment 6 Gerald (Jerry) Carter (dead mail address) 2005-02-07 09:06:20 UTC
originally reported against one of the 3.0.0rc[1-4] releases.
Cleaning up non-production versions.
Comment 7 Gerald (Jerry) Carter (dead mail address) 2005-08-24 10:28:10 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.