Bug 776 - Client API not handling multi-byte ASCII
Client API not handling multi-byte ASCII
Status: CLOSED INVALID
Product: Samba 3.0
Classification: Unclassified
Component: libsmbclient
3.0.0
Other FreeBSD
: P2 critical
: none
Assigned To: Samba Bugzilla Account
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-11-13 17:16 UTC by Jonny Larson
Modified: 2004-08-24 09:33 UTC (History)
0 users

See Also:


Attachments
lib/charcnv.c -- Has change corresponding to diff I put in the description. (28.30 KB, text/plain)
2003-11-17 10:39 UTC, Jonny Larson
no flags Details
libsmb/clilist.c -- Has change corresponding to diff I put in the description (12.78 KB, text/plain)
2003-11-17 10:40 UTC, Jonny Larson
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonny Larson 2003-11-13 17:16:12 UTC
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
718,725d717
< #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, 
dest_len);
<         else
< #endif
Comment 1 Jonny Larson 2003-11-13 17:20:29 UTC
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
85c85
<                       int namelen, slen, flags = 0;
---
>                       int namelen, slen;
130,134d129
<
< #ifndef HAVE_NATIVE_ICONV
<                         if ((cli->capabilities & CAP_UNICODE) == 0)
<                             flags = STR_ASCII;
< #endif
137c132
<                                   namelen, flags);
---
>                                   namelen, 0);
Comment 2 Andrew Bartlett 2003-11-16 01:56:54 UTC
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.  

Thanks,
Comment 3 Jonny Larson 2003-11-17 10:38:05 UTC
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 @@
                }
        }

+#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, dest_len);
+        else
+#endif
        ret = convert_string(CH_DOS, CH_UNIX, src, src_len, dest, dest_len);

        if (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 @@
                                            slen, flags);
                        }
                        p += 24; /* short name? */
+
+#ifndef HAVE_NATIVE_ICONV
+                        if ((cli->capabilities & CAP_UNICODE) == 0)
+                            flags = STR_ASCII;
+#endif
                        clistr_pull(cli, finfo->name, p,
                                    sizeof(finfo->name),
-                                   namelen, 0);
+                                   namelen, flags);
                        return SVAL(base, 0);
                }
        }
Comment 4 Jonny Larson 2003-11-17 10:39:51 UTC
Created attachment 259 [details]
lib/charcnv.c -- Has change corresponding to diff I put in the description.
Comment 5 Jonny Larson 2003-11-17 10:40:52 UTC
Created attachment 260 [details]
libsmb/clilist.c -- Has change corresponding to diff I put in the description
Comment 6 Jonny Larson 2003-11-20 11:36:32 UTC
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.
Comment 7 Björn Jacke 2004-08-24 09:24:49 UTC
was no bug