I'm using the Samba 3.0.0 client API. Older Samba servers (such as 2.2.3a)
send data streams in ASCII (the CAP_UNICODE bit is not set in the capabilities
field). When the file server has multi-byte file and directory names (such as
Japanese), the names are mashed by the internal charset conversion routines
(such as utf8_pull). Consequently, the file/dir names are garbage when our
callback routines are called. The Samba code needs to merely use iconv_copy
when the data stream is ASCII.
I've made changes to the Samba code. The updated code works fine in the
testing I've done with both single-byte and multi-byte file and dir names.
We did not compile in the ICONV
I wanted to attach the two files I changed (lib/charcnv.c, libsmb/clilist.c)
but I don't see an attach button here. As such, here's the diffs:
samba/source/lib> diff charcnv.c charcnv.old
< #ifndef HAVE_NATIVE_ICONV
< // JTL 11/13/2003
< // If the other side is sending ASCII, don't try to convert it!
< if (flags & STR_ASCII)
< ret = convert_string(CH_DOS, CH_DOS, src, src_len, dest,
Here's the rest:
We did not compile in the ICONV or GICONV support.
Here's the other diff:
samba/source/libsmb/diff clilist.c clilist.old
< int namelen, slen, flags = 0;
> int namelen, slen;
< #ifndef HAVE_NATIVE_ICONV
< if ((cli->capabilities & CAP_UNICODE) == 0)
< flags = STR_ASCII;
< namelen, flags);
> namelen, 0);
Please attach files (you can see the attach button now :-) in
diff -u oldfile newfile
format. Note that we should never have inline #ifdefs like that however - if we
don't have iconv() we might still be using our internal replacement.
Here's the diff's in the requested format:
samba/source/lib> diff -u charcnv.old charcnv.c
--- charcnv.old Thu Nov 13 17:12:39 2003
+++ charcnv.c Mon Nov 17 10:30:50 2003
@@ -715,6 +715,13 @@
+ // JTL 11/13/2003
+ // If the other side is sending ASCII, don't try to convert it!
+ if (flags & STR_ASCII)
+ ret = convert_string(CH_DOS, CH_DOS, src, src_len, dest, dest_len);
ret = convert_string(CH_DOS, CH_UNIX, src, src_len, dest, dest_len);
samba/source/libsmb> diff -u clilist.old clilist.c
--- clilist.old Thu Nov 13 17:17:49 2003
+++ clilist.c Thu Nov 13 17:15:53 2003
@@ -82,7 +82,7 @@
case 260: /* NT uses this, but also accepts 2 */
- int namelen, slen;
+ int namelen, slen, flags = 0;
p += 4; /* next entry offset */
p += 4; /* fileindex */
@@ -127,9 +127,14 @@
p += 24; /* short name? */
+ if ((cli->capabilities & CAP_UNICODE) == 0)
+ flags = STR_ASCII;
clistr_pull(cli, finfo->name, p,
- namelen, 0);
+ namelen, flags);
return SVAL(base, 0);
Created attachment 259 [details]
lib/charcnv.c -- Has change corresponding to diff I put in the description.
Created attachment 260 [details]
libsmb/clilist.c -- Has change corresponding to diff I put in the description
Specifying a dos charset = <some non-existent codepage> in the smb.conf file
causes Samba to pass ASCII data through with no conversion. This fixes the
problem and negates the need for my changes.
I don't have authority to change the status of this issue. Feel free to close
it as you see fit.
was no bug