[jcifs] Problem reading files from a share

Eric Glass eric.glass at gmail.com
Tue Nov 7 17:41:21 GMT 2006


UTF-16LE is the "standard" name for this encoding (required to be
supported in any JVM).  UnicodeLittleUnmarked is a Sun-specific name
(but is what UTF-16LE maps to internally):

http://java.sun.com/j2se/1.3/docs/guide/intl/encoding.doc.html


On 11/7/06, Michael B Allen <mba2000 at ioplex.com> wrote:
> We should definitely be using UnicodeLittleUnmarked. We do mostly but
> somehow some UnicodeLittle crept in. This is definitely going on The List
> (actually I thought it was already).
>
> Grep says there are 4 instances that need to be changed:
>
> jcifs/smb/SmbComSessionSetupAndXResponse.java: primaryDomain = new String( buffer, bufferIndex, len, "UnicodeLittle" );
> jcifs/smb/ServerMessageBlock.java: str = new String( src, srcIndex, len, "UnicodeLittle" );
> jcifs/smb/SmbComNegotiateResponse.java:   len, "UnicodeLittle" );
> jcifs/smb/Trans2FindFirst2Response.java:  str = new String( src, srcIndex, len, "UnicodeLittle" );
>
> Mike
>
> On Tue, 07 Nov 2006 10:14:36 +0100
> Ingo Rockel <irockel at pironet-ndh.com> wrote:
>
> > Hi,
> >
> > we did some further analysis and it looks like it is caused by this issue:
> >
> > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6448787
> >
> > So my question: should UnicodeLittleUnmarked used from now on? (That
> > encoding works, see last comment in bug)
> >
> > regards,
> >
> >       Ingo
> >
> > Ingo Rockel schrieb:
> > > Hi Mike,
> > >
> > > thanx for the hint, but it looks like the mentioned code never gets
> > > called in the example, so no HexDump-Output.
> > >
> > > I've attached the example again inline, so it doesn't get stripped:
> > >
> > > import java.io.PrintStream;
> > > import java.net.URL;
> > > import jcifs.Config;
> > > import jcifs.smb.SmbFile;
> > >
> > > public class JCifsTest1
> > > {
> > >     public static void main(String args[])
> > >         throws Exception
> > >     {
> > >         if(args[0].lastIndexOf('/') != args[0].length() - 1)
> > >             args[0] = args[0].substring(0, args[0].length() - 1);
> > >         System.out.println("****** Argument: >>>" + args[0] + "<<<");
> > >         System.out.println("****** new SmbFile");
> > >         Config.registerSmbURLHandler();
> > >         SmbFile smbfile = new SmbFile(args[0]);
> > >         long l = System.currentTimeMillis();
> > >         System.out.println("file.getURL().getPath(): " +
> > > smbfile.getURL().getPath());
> > >         System.out.println("file.getPath(): " + smbfile.getPath());
> > >         String s = smbfile.getURL().getPath();
> > >         System.out.println("p: >>" + s + "<<");
> > >         System.out.println("lastIndexOf: " + s.lastIndexOf('/'));
> > >         System.out.println("length: " + s.length());
> > >         if(s.lastIndexOf('/') != s.length() - 1)
> > >             System.out.println("DEBUG: " + smbfile.getURL().getPath() +
> > > " directory must end with '/' !!!!");
> > >         else
> > >             System.out.println("DEBUG: " + smbfile.getURL().getPath() +
> > > " directory is ok");
> > >         System.out.println();
> > >         System.out.println();
> > >         System.out.println();
> > >         System.out.println();
> > >         System.out.flush();
> > >         System.out.println("****** file.listFiles");
> > >         SmbFile asmbfile[] = smbfile.listFiles();
> > >         long l1 = System.currentTimeMillis() - l;
> > >         System.out.println("****** loop files");
> > >         for(int i = 0; i < asmbfile.length; i++)
> > >             System.out.println("****** " + asmbfile[i]);
> > >
> > >         System.out.println();
> > >         System.out.println(asmbfile.length + " files in " + l1 + "ms");
> > >     }
> > > }
> > >
> > > thanx,
> > >
> > >     Ingo
> > >
> > > Michael B Allen schrieb:
> > >> I think your attachment got stripped but it sure looks like an encoding
> > >> problem. But the fact that it happends in a new build of Sun's JRE is
> > >> interesting in itself. Try adding a Hexdump.hexdump() call just before
> > >> src/jcifs/smb/NetShareEnumResponse.java:105.
> > >>
> > >> Mike
> > >>
> > >> On Thu, 26 Oct 2006 14:44:49 +0200
> > >> Ingo Rockel <irockel at pironet-ndh.com> wrote:
> > >>
> > >>> Hi all,
> > >>>
> > >>> we recently switched to j2sdk1.4.2_12 and there we have a Problem
> > >>> fetching contents of a share using jcifs. The problem doesn't exists
> > >>> in j2sdk1.4.2_11 nor in jdk1.5.0_08 nor recent RC of 1.6.
> > >>>
> > >>> I've attached a small test class demonstrating the problem. The class
> > >>> tries to connect to a share passed as param (something like
> > >>> "smb://user:pw@some.machine/some_share/") and lists the content. With
> > >>> all jdks except 1.4.2_12 the result is ok, but with 1.4.2_12
> > >>> something like this is returned:
> > >>>
> > >>> ****** loop files
> > >>> ****** smb://x:x@some.server/webdav_test/?/
> > >>> ****** smb://x:x@some.server/webdav_test/??/
> > >>> ****** smb://x:x@some.server/webdav_test/???????????????
> > >>> ****** smb://x:x@some.server/webdav_test/????????????/
> > >>> ****** smb://x:x@some.server/webdav_test/??/
> > >>> ****** smb://x:x@some.server/webdav_test/??????????
> > >>> ****** smb://x:x@some.server/webdav_test/???????????????
> > >>>
> > >>> I tried connections to (german) win2000 and win2003 server, both
> > >>> return the result above. If connecting to a smb-server running on
> > >>> linux the result is ok. I tried setting jcifs.encoding to different
> > >>> values (cp1252, utf8) but without any success.
> > >>>
> > >>> I checked the release notes of 1.4.2_12 but anything of the changes
> > >>> looks like it affects this.
> > >>>
> > >>> Any Ideas?
> > >>>
> > >>> Ingo
> > >>>
> > >>> --
> > >>> PIRONET NDH AG
> > >>> Dipl. Inf. Ingo Rockel - Produktentwicklung
> > >>> Maarweg 149-161, 50825 Koeln
> > >>> Tel.: +49 (0)221-770-1788 / Fax: +49 (0)221-770-1005
> > >>> mailto:irockel at pironet-ndh.com - http://www.pironet-ndh.com
> > >>>
> > >>
> > >>
> > >
> > >
> >
> >
> > --
> > PIRONET NDH AG
> > Dipl. Inf. Ingo Rockel - Produktentwicklung
> > Maarweg 149-161, 50825 Koeln
> > Tel.: +49 (0)221-770-1788 / Fax: +49 (0)221-770-1005
> > mailto:irockel at pironet-ndh.com - http://www.pironet-ndh.com
> >
>
>
> --
> Michael B Allen
> PHP Active Directory SSO
> http://www.ioplex.com/
>


More information about the jcifs mailing list