jcifs-1.3.17 from tgz
authorFelix Schumacher <felix.schumacher@internetallee.de>
Sun, 13 Nov 2011 11:04:55 +0000 (12:04 +0100)
committerFelix Schumacher <felix.schumacher@internetallee.de>
Sun, 13 Nov 2011 11:04:55 +0000 (12:04 +0100)
Tue Oct 18 15:10:23 EDT 2011
jcifs-1.3.17

The jcifs.smb.client.soTimeout property, which controls how long the
client will wait to read data from a server, was broken in the previous
release (1.3.16). Not only was it broken but no SO_TIMEOUT was specified
at all meaning if a server became unresponive, JCIFS could hang for
an uncontrollably long time. This behavior of this property has been
restored.

Additionally, a new jcifs.smb.client.connTimeout has been added which
specifies the number of milliseconds that the client will wait to
connect to a server (how long it will wait for a response to the TCP
SYN). This can be very useful when trying to communicate with many
servers in parallel.

README.txt
build.xml
examples/runtests.sh
patches/LargeReadWrite.patch
patches/LargeReadWrite2005.patch [new file with mode: 0644]
src/jcifs/smb/NtlmPasswordAuthentication.java
src/jcifs/smb/SmbConstants.java
src/jcifs/smb/SmbTransport.java

index 27c94dd..0904d87 100644 (file)
@@ -1,3 +1,68 @@
+Tue Oct 18 15:10:23 EDT 2011
+jcifs-1.3.17
+
+The jcifs.smb.client.soTimeout property, which controls how long the
+client will wait to read data from a server, was broken in the previous
+release (1.3.16). Not only was it broken but no SO_TIMEOUT was specified
+at all meaning if a server became unresponive, JCIFS could hang for
+an uncontrollably long time. This behavior of this property has been
+restored.
+
+Additionally, a new jcifs.smb.client.connTimeout has been added which
+specifies the number of milliseconds that the client will wait to
+connect to a server (how long it will wait for a response to the TCP
+SYN). This can be very useful when trying to communicate with many
+servers in parallel.
+
+Sat Jun 25 12:00:00 EDT 2011
+jcifs-1.3.16
+
+This release includes the following minor fixes and improvements:
+
+  * JCIFS now uses the InetSocketAddress class to explicitly bind and
+  set the SO_TIMEOUT on client sockets before they are connected. This
+  makes the SO_TIMEOUT effective when the target server socket is not
+  listening and the client OS socket implementation takes a long time
+  for the dropped SYN to timeout. This may significantly reduce resource
+  consumption in applications that use multiple threads to constantly
+  query servers that may not be listening.
+
+  * When disconnecting a transport, new clauses have been added to better
+  reset transport state whereas previously transports could get stuck
+  in a disconnected state for unnecessarily long periods of time.
+
+  * A new property jcifs.smb.client.ignoreCopyToException has been
+  added. When set to "true" (the default), the SmbFile.copyTo() method
+  will ignore (but log) exceptions trying to copy individual files or
+  directories (such as because of a permissions error). To maintain
+  backward compatibility, the default value of this property is "true"
+  (exceptions are ignored). Setting this property to "false" will cause
+  any exception that occurs trying to copy an individual file or directory
+  to be thrown out of copyTo and abort the copy operation at the point
+  of failure.
+
+  * If an authentication exception occurs trying to connect to a server
+  that has multiple IP addresses, JCIFS will not attempt to connect
+  to more than one IP addresses because doing so could result in an
+  account lockout.
+
+  * The SID resolver code incorrectly resolved SIDs of an ACE in blocks
+  of at most 10 where it should have used a limit of 64. This performance
+  issue has been fixed.
+
+  * JCIFS will not throw the artifical "Access is denied" error if the
+  special NtlmPasswordCredential.ANONYMOUS credential is used explicitly
+  (whereas normally JCIFS will deliberately throw an SmbAuthException if
+  a login results in a guest login or if the anonymous identity is used).
+
+  * The NetrServerEnum2 RAP call used incorrect parameter descriptiors
+  which could result in "SmbException: 2320" errors trying to list
+  domains and servers from the local NetBIOS browse service.
+
+  * The NTLMSSP AUTHENTICATE_MESSAGE (aka "Type 2 Message") encoding
+  routine incorrectly left out the TargetName field (although this had
+  no effect on CIFS client behavior).
+
 Thu Oct  7 13:36:57 EDT 2010
 jcifs-1.3.15
 
@@ -6,9 +71,6 @@ result in "All pipe instances are busy". This is also believed to reduce
 occurances of NT_STATUS_TOO_MANY_OPENED_FILES errors (although when
 resolving SID names excessively, this error can still occur).
 
-Thu Aug 19 21:05:38 EDT 2010
-jcifs-1.3.15a
-
 Fragmented request PDUs have been implemented.
 
 Thu Feb 11 15:10:26 EST 2010
index cb68a72..ad5b2b6 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -1,7 +1,7 @@
 <project name="jcifs" default="usage" basedir=".">
 
-    <property name="version" value="1.3.16"/>
-    <property name="reldate" value="Jun 23, 2011"/>
+    <property name="version" value="1.3.17"/>
+    <property name="reldate" value="Oct 18, 2011"/>
 
     <target name="usage">
         <echo>
index 4b22758..e643db2 100644 (file)
@@ -41,6 +41,7 @@ $RUN TestGetParent ${URL_WRITE_DIR}
 $RUN TestListLoop 'smb://dc5.w.net/tmp/' 2
 $RUN TestCopy smb://fs1.w.net/tmp/xxx/ smb://dc5.w.net/tmp/deleteme/
 $RUN ListFiles smb://
+$RUN ListFiles smb://192.168.15.110/tmp/
 $RUN ListACL ${URL_WRITE_DIR}
 $RUN LargeListFiles ${URL_WRITE_DIR}
 $RUN CountPerms ${URL_WRITE_DIR} 100
index ba96f7c..5c46ed2 100644 (file)
-diff -Naur ../jcifs_1.2.6_org/src/jcifs/smb/SmbConstants.java src/jcifs/smb/SmbConstants.java
---- ../jcifs_1.2.6_org/src/jcifs/smb/SmbConstants.java  Fri Oct 07 17:56:54 2005
-+++ src/jcifs/smb/SmbConstants.java Tue Oct 18 12:16:06 2005
-@@ -13,7 +13,7 @@
-     static final int DEFAULT_RESPONSE_TIMEOUT = 10000;
-     static final int DEFAULT_SO_TIMEOUT = 15000;
-     static final int DEFAULT_RCV_BUF_SIZE = 60416;
--    static final int DEFAULT_SND_BUF_SIZE = 16644;
-+    static final int DEFAULT_SND_BUF_SIZE = 60416;
-     static final int DEFAULT_SSN_LIMIT = 250;
-     static final InetAddress LADDR = Config.getLocalHost();
-@@ -61,6 +61,8 @@
-     static final int CAP_LOCK_AND_READ    = 0x0100;
-     static final int CAP_NT_FIND          = 0x0200;
-     static final int CAP_DFS              = 0x1000;
-+    static final int CAP_LARGE_READX      = 0x4000;
-+    static final int CAP_LARGE_WRITEX     = 0x8000;
-     // file attribute encoding
-     static final int ATTR_READONLY   = 0x01;
-@@ -117,7 +119,10 @@
-                 ( USE_NTSMBS ? CAP_NT_SMBS : 0 ) |
-                 ( USE_NTSTATUS ? CAP_STATUS32 : 0 ) |
-                 ( USE_UNICODE ? CAP_UNICODE : 0 ) |
--                CAP_DFS;
-+                CAP_DFS |
-+               CAP_LARGE_READX |
-+               CAP_LARGE_WRITEX;
-+
-     static final int FLAGS2 = Config.getInt( "jcifs.smb.client.flags2", DEFAULT_FLAGS2 );
-     static final int CAPABILITIES = Config.getInt( "jcifs.smb.client.capabilities", DEFAULT_CAPABILITIES );
-     static final boolean TCP_NODELAY = Config.getBoolean( "jcifs.smb.client.tcpNoDelay", false );
-diff -Naur ../jcifs_1.2.6_org/src/jcifs/smb/SmbFileInputStream.java src/jcifs/smb/SmbFileInputStream.java
---- ../jcifs_1.2.6_org/src/jcifs/smb/SmbFileInputStream.java    Fri Oct 07 17:56:54 2005
-+++ src/jcifs/smb/SmbFileInputStream.java   Wed Oct 19 14:00:24 2005
-@@ -32,6 +32,7 @@
-     private long fp;
-     private int readSize, openFlags;
-+    private int readSizeFile;
-     private byte[] tmp = new byte[1];
-     SmbFile file;
-@@ -73,6 +74,12 @@
-         }
-         readSize = Math.min( file.tree.session.transport.rcv_buf_size - 70,
-                             file.tree.session.transport.server.maxBufferSize - 70 );
-+
-+        if(file.tree.session.transport.hasCapability(SmbConstants.CAP_LARGE_READX)) {
-+            readSizeFile = Math.min(SmbConstants.RCV_BUF_SIZE - 70, 0xF000);
-+        } else {
-+            readSizeFile = readSize;
-+        }
-     }
- /**
-@@ -143,7 +150,9 @@
-         int r, n;
-         do {
--            r = len > readSize ? readSize : len;
-+            int blockSize = (file.getType() == SmbFile.TYPE_FILESYSTEM) ? readSizeFile : readSize;
-+            
-+            r = len > blockSize ? blockSize : len;
+### Eclipse Workspace Patch 1.0
+#P jcifs
+Index: src/jcifs/smb/SmbFileOutputStream.java
+===================================================================
+--- src/jcifs/smb/SmbFileOutputStream.java  (revision 54857)
++++ src/jcifs/smb/SmbFileOutputStream.java  (working copy)
+@@ -33,7 +33,7 @@
  
-             if( file.log.level > 2 )
-                 file.log.println( "read: len=" + len + ",r=" + r + ",fp=" + fp );
-diff -Naur ../jcifs_1.2.6_org/src/jcifs/smb/SmbFileOutputStream.java src/jcifs/smb/SmbFileOutputStream.java
---- ../jcifs_1.2.6_org/src/jcifs/smb/SmbFileOutputStream.java   Fri Oct 07 17:56:54 2005
-+++ src/jcifs/smb/SmbFileOutputStream.java  Wed Oct 19 13:57:14 2005
-@@ -34,6 +34,7 @@
      private SmbFile file;
      private boolean append, useNTSmbs;
-     private int openFlags, writeSize;
-+    private int writeSizeFile;
+-    private int openFlags, access, writeSize;
++    private int openFlags, writeSizeFile, access, writeSize;
      private long fp;
      private byte[] tmp = new byte[1];
      private SmbComWriteAndX reqx;
-@@ -138,7 +139,14 @@
-         }
-         file.open( openFlags, SmbFile.ATTR_NORMAL, 0 );
+@@ -142,6 +142,11 @@
+         file.open( openFlags, access | SmbConstants.FILE_WRITE_DATA, SmbFile.ATTR_NORMAL, 0 );
          this.openFlags &= ~(SmbFile.O_CREAT | SmbFile.O_TRUNC); /* in case close and reopen */
--        writeSize = file.tree.session.transport.snd_buf_size - 70;
-+        writeSize = Math.min( file.tree.session.transport.snd_buf_size - 70,
-+                              file.tree.session.transport.server.maxBufferSize - 70 );
-+        
-+        if(file.tree.session.transport.hasCapability(SmbConstants.CAP_LARGE_WRITEX)) {
-+            writeSizeFile = Math.min(SmbConstants.SND_BUF_SIZE - 70, 0xF000);
+         writeSize = file.tree.session.transport.snd_buf_size - 70;
++        if((file.tree.session.transport.server.capabilities & SmbConstants.CAP_LARGE_WRITEX) == SmbConstants.CAP_LARGE_WRITEX) {
++            writeSizeFile = Math.min(SmbConstants.RCV_BUF_SIZE - 70, 0xFFFF - 70);
 +        } else {
 +            writeSizeFile = writeSize;
 +        }
  
          useNTSmbs = file.tree.session.transport.hasCapability( ServerMessageBlock.CAP_NT_SMBS );
          if( useNTSmbs ) {
-@@ -217,7 +225,9 @@
+@@ -233,15 +238,17 @@
  
          int w;
          do {
 -            w = len > writeSize ? writeSize : len;
 +            int blockSize = (file.getType() == SmbFile.TYPE_FILESYSTEM) ? writeSizeFile : writeSize;
-+            
 +            w = len > blockSize ? blockSize : len;
++
              if( useNTSmbs ) {
                  reqx.setParam( file.fid, fp, len - w, b, off, w );
+-if ((flags & 1) != 0) {
+-    reqx.setParam( file.fid, fp, len, b, off, w );
+-    reqx.writeMode = 0x8;
+-} else {
+-    reqx.writeMode = 0;
+-}
++            if ((flags & 1) != 0) {
++                reqx.setParam( file.fid, fp, len, b, off, w );
++                reqx.writeMode = 0x8;
++            } else {
++                reqx.writeMode = 0;
++            }
                  file.send( reqx, rspx );
-diff -Naur ../jcifs_1.2.6_org/src/jcifs/smb/SmbRandomAccessFile.java src/jcifs/smb/SmbRandomAccessFile.java
---- ../jcifs_1.2.6_org/src/jcifs/smb/SmbRandomAccessFile.java   Fri Oct 07 17:56:54 2005
-+++ src/jcifs/smb/SmbRandomAccessFile.java  Wed Oct 19 14:20:45 2005
-@@ -54,8 +54,20 @@
+                 fp += rspx.count;
+                 len -= rspx.count;
+Index: src/jcifs/smb/SmbRandomAccessFile.java
+===================================================================
+--- src/jcifs/smb/SmbRandomAccessFile.java  (revision 54857)
++++ src/jcifs/smb/SmbRandomAccessFile.java  (working copy)
+@@ -55,8 +55,19 @@
              throw new IllegalArgumentException( "Invalid mode" );
          }
-         file.open( openFlags, SmbFile.ATTR_NORMAL, options );
+         file.open( openFlags, access, SmbFile.ATTR_NORMAL, options );
 -        readSize = file.tree.session.transport.rcv_buf_size - 70;
 -        writeSize = file.tree.session.transport.snd_buf_size - 70;
 +        
-+        if(file.tree.session.transport.hasCapability(SmbConstants.CAP_LARGE_READX)) {
-+            readSize = Math.min(SmbConstants.RCV_BUF_SIZE - 70, 0xF000);
++      if((file.tree.session.transport.server.capabilities & SmbConstants.CAP_LARGE_READX) == SmbConstants.CAP_LARGE_READX) {
++            readSize = Math.min(SmbConstants.RCV_BUF_SIZE - 70, 0xFFFF -70);
 +        } else {
 +            readSize = file.tree.session.transport.rcv_buf_size - 70;
 +        }
 +        
-+        if(file.tree.session.transport.hasCapability(SmbConstants.CAP_LARGE_WRITEX)) {
-+            writeSize = Math.min(SmbConstants.SND_BUF_SIZE - 70, 0xF000);
++        if((file.tree.session.transport.server.capabilities & SmbConstants.CAP_LARGE_WRITEX) == SmbConstants.CAP_LARGE_WRITEX) {
++            writeSize = Math.min(SmbConstants.SND_BUF_SIZE - 70, 0xFFFF - 70);
 +        } else {
 +            writeSize = Math.min( file.tree.session.transport.snd_buf_size - 70,
 +                                  file.tree.session.transport.server.maxBufferSize - 70 );
 +        }
-+        
          fp = 0L;
      }
+Index: src/jcifs/smb/SmbConstants.java
+===================================================================
+--- src/jcifs/smb/SmbConstants.java (revision 54857)
++++ src/jcifs/smb/SmbConstants.java (working copy)
+@@ -12,8 +12,8 @@
+     static final int DEFAULT_MAX_MPX_COUNT = 10;
+     static final int DEFAULT_RESPONSE_TIMEOUT = 30000;
+     static final int DEFAULT_SO_TIMEOUT = 35000;
+-    static final int DEFAULT_RCV_BUF_SIZE = 60416;
+-    static final int DEFAULT_SND_BUF_SIZE = 16644;
++   static final int DEFAULT_RCV_BUF_SIZE = 0xFFFF;
++   static final int DEFAULT_SND_BUF_SIZE = 0xFFFF;
+     static final int DEFAULT_SSN_LIMIT = 250;
+     static final InetAddress LADDR = Config.getLocalHost();
+@@ -61,7 +61,9 @@
+     static final int CAP_LEVEL_II_OPLOCKS = 0x0080;
+     static final int CAP_LOCK_AND_READ    = 0x0100;
+     static final int CAP_NT_FIND          = 0x0200;
+-    static final int CAP_DFS              = 0x1000;
++    static final int CAP_DFS              = 0x1000;
++   static final int CAP_LARGE_READX = 0x4000;
++   static final int CAP_LARGE_WRITEX = 0x8000;
+     static final int CAP_EXTENDED_SECURITY = 0x80000000;
+     // file attribute encoding
+Index: src/jcifs/smb/SmbFileInputStream.java
+===================================================================
+--- src/jcifs/smb/SmbFileInputStream.java   (revision 54857)
++++ src/jcifs/smb/SmbFileInputStream.java   (working copy)
+@@ -34,7 +34,7 @@
+ public class SmbFileInputStream extends InputStream {
+     private long fp;
+-    private int readSize, openFlags, access;
++    private int readSize, readSizeFile, openFlags, access;
+     private byte[] tmp = new byte[1];
+     SmbFile file;
+@@ -76,7 +76,12 @@
+             file.connect0();
+         }
+         readSize = Math.min( file.tree.session.transport.rcv_buf_size - 70,
+-                            file.tree.session.transport.server.maxBufferSize - 70 );
++                            file.tree.session.transport.server.maxBufferSize - 70 );
++        if((file.tree.session.transport.server.capabilities & SmbConstants.CAP_LARGE_READX) == SmbConstants.CAP_LARGE_READX) {
++            readSizeFile = Math.min(SmbConstants.RCV_BUF_SIZE - 70, 0xFFFF - 70);
++        } else {
++            readSizeFile = readSize;
++        }
+     }
+     protected IOException seToIoe(SmbException se) {
+@@ -168,7 +173,8 @@
+         int r, n;
+         do {
+-            r = len > readSize ? readSize : len;
++            int blockSize = (file.getType() == SmbFile.TYPE_FILESYSTEM) ? readSizeFile : readSize;
++            r = len > blockSize ? blockSize : len;
+             if( file.log.level >= 4 )
+                 file.log.println( "read: len=" + len + ",r=" + r + ",fp=" + fp );
diff --git a/patches/LargeReadWrite2005.patch b/patches/LargeReadWrite2005.patch
new file mode 100644 (file)
index 0000000..ba96f7c
--- /dev/null
@@ -0,0 +1,131 @@
+diff -Naur ../jcifs_1.2.6_org/src/jcifs/smb/SmbConstants.java src/jcifs/smb/SmbConstants.java
+--- ../jcifs_1.2.6_org/src/jcifs/smb/SmbConstants.java  Fri Oct 07 17:56:54 2005
++++ src/jcifs/smb/SmbConstants.java Tue Oct 18 12:16:06 2005
+@@ -13,7 +13,7 @@
+     static final int DEFAULT_RESPONSE_TIMEOUT = 10000;
+     static final int DEFAULT_SO_TIMEOUT = 15000;
+     static final int DEFAULT_RCV_BUF_SIZE = 60416;
+-    static final int DEFAULT_SND_BUF_SIZE = 16644;
++    static final int DEFAULT_SND_BUF_SIZE = 60416;
+     static final int DEFAULT_SSN_LIMIT = 250;
+     static final InetAddress LADDR = Config.getLocalHost();
+@@ -61,6 +61,8 @@
+     static final int CAP_LOCK_AND_READ    = 0x0100;
+     static final int CAP_NT_FIND          = 0x0200;
+     static final int CAP_DFS              = 0x1000;
++    static final int CAP_LARGE_READX      = 0x4000;
++    static final int CAP_LARGE_WRITEX     = 0x8000;
+     // file attribute encoding
+     static final int ATTR_READONLY   = 0x01;
+@@ -117,7 +119,10 @@
+                 ( USE_NTSMBS ? CAP_NT_SMBS : 0 ) |
+                 ( USE_NTSTATUS ? CAP_STATUS32 : 0 ) |
+                 ( USE_UNICODE ? CAP_UNICODE : 0 ) |
+-                CAP_DFS;
++                CAP_DFS |
++               CAP_LARGE_READX |
++               CAP_LARGE_WRITEX;
++
+     static final int FLAGS2 = Config.getInt( "jcifs.smb.client.flags2", DEFAULT_FLAGS2 );
+     static final int CAPABILITIES = Config.getInt( "jcifs.smb.client.capabilities", DEFAULT_CAPABILITIES );
+     static final boolean TCP_NODELAY = Config.getBoolean( "jcifs.smb.client.tcpNoDelay", false );
+diff -Naur ../jcifs_1.2.6_org/src/jcifs/smb/SmbFileInputStream.java src/jcifs/smb/SmbFileInputStream.java
+--- ../jcifs_1.2.6_org/src/jcifs/smb/SmbFileInputStream.java    Fri Oct 07 17:56:54 2005
++++ src/jcifs/smb/SmbFileInputStream.java   Wed Oct 19 14:00:24 2005
+@@ -32,6 +32,7 @@
+     private long fp;
+     private int readSize, openFlags;
++    private int readSizeFile;
+     private byte[] tmp = new byte[1];
+     SmbFile file;
+@@ -73,6 +74,12 @@
+         }
+         readSize = Math.min( file.tree.session.transport.rcv_buf_size - 70,
+                             file.tree.session.transport.server.maxBufferSize - 70 );
++
++        if(file.tree.session.transport.hasCapability(SmbConstants.CAP_LARGE_READX)) {
++            readSizeFile = Math.min(SmbConstants.RCV_BUF_SIZE - 70, 0xF000);
++        } else {
++            readSizeFile = readSize;
++        }
+     }
+ /**
+@@ -143,7 +150,9 @@
+         int r, n;
+         do {
+-            r = len > readSize ? readSize : len;
++            int blockSize = (file.getType() == SmbFile.TYPE_FILESYSTEM) ? readSizeFile : readSize;
++            
++            r = len > blockSize ? blockSize : len;
+             if( file.log.level > 2 )
+                 file.log.println( "read: len=" + len + ",r=" + r + ",fp=" + fp );
+diff -Naur ../jcifs_1.2.6_org/src/jcifs/smb/SmbFileOutputStream.java src/jcifs/smb/SmbFileOutputStream.java
+--- ../jcifs_1.2.6_org/src/jcifs/smb/SmbFileOutputStream.java   Fri Oct 07 17:56:54 2005
++++ src/jcifs/smb/SmbFileOutputStream.java  Wed Oct 19 13:57:14 2005
+@@ -34,6 +34,7 @@
+     private SmbFile file;
+     private boolean append, useNTSmbs;
+     private int openFlags, writeSize;
++    private int writeSizeFile;
+     private long fp;
+     private byte[] tmp = new byte[1];
+     private SmbComWriteAndX reqx;
+@@ -138,7 +139,14 @@
+         }
+         file.open( openFlags, SmbFile.ATTR_NORMAL, 0 );
+         this.openFlags &= ~(SmbFile.O_CREAT | SmbFile.O_TRUNC); /* in case close and reopen */
+-        writeSize = file.tree.session.transport.snd_buf_size - 70;
++        writeSize = Math.min( file.tree.session.transport.snd_buf_size - 70,
++                              file.tree.session.transport.server.maxBufferSize - 70 );
++        
++        if(file.tree.session.transport.hasCapability(SmbConstants.CAP_LARGE_WRITEX)) {
++            writeSizeFile = Math.min(SmbConstants.SND_BUF_SIZE - 70, 0xF000);
++        } else {
++            writeSizeFile = writeSize;
++        }
+         useNTSmbs = file.tree.session.transport.hasCapability( ServerMessageBlock.CAP_NT_SMBS );
+         if( useNTSmbs ) {
+@@ -217,7 +225,9 @@
+         int w;
+         do {
+-            w = len > writeSize ? writeSize : len;
++            int blockSize = (file.getType() == SmbFile.TYPE_FILESYSTEM) ? writeSizeFile : writeSize;
++            
++            w = len > blockSize ? blockSize : len;
+             if( useNTSmbs ) {
+                 reqx.setParam( file.fid, fp, len - w, b, off, w );
+                 file.send( reqx, rspx );
+diff -Naur ../jcifs_1.2.6_org/src/jcifs/smb/SmbRandomAccessFile.java src/jcifs/smb/SmbRandomAccessFile.java
+--- ../jcifs_1.2.6_org/src/jcifs/smb/SmbRandomAccessFile.java   Fri Oct 07 17:56:54 2005
++++ src/jcifs/smb/SmbRandomAccessFile.java  Wed Oct 19 14:20:45 2005
+@@ -54,8 +54,20 @@
+             throw new IllegalArgumentException( "Invalid mode" );
+         }
+         file.open( openFlags, SmbFile.ATTR_NORMAL, options );
+-        readSize = file.tree.session.transport.rcv_buf_size - 70;
+-        writeSize = file.tree.session.transport.snd_buf_size - 70;
++        
++        if(file.tree.session.transport.hasCapability(SmbConstants.CAP_LARGE_READX)) {
++            readSize = Math.min(SmbConstants.RCV_BUF_SIZE - 70, 0xF000);
++        } else {
++            readSize = file.tree.session.transport.rcv_buf_size - 70;
++        }
++        
++        if(file.tree.session.transport.hasCapability(SmbConstants.CAP_LARGE_WRITEX)) {
++            writeSize = Math.min(SmbConstants.SND_BUF_SIZE - 70, 0xF000);
++        } else {
++            writeSize = Math.min( file.tree.session.transport.snd_buf_size - 70,
++                                  file.tree.session.transport.server.maxBufferSize - 70 );
++        }
++        
+         fp = 0L;
+     }
index c453540..7f2eb18 100644 (file)
@@ -330,15 +330,17 @@ public final class NtlmPasswordAuthentication implements Principal, Serializable
     public NtlmPasswordAuthentication( String domain, String username, String password ) {
         int ci;
 
-        ci = username.indexOf('@');
-        if (ci > 0) {
-            domain = username.substring(ci + 1);
-            username = username.substring(0, ci);
-        } else {
-            ci = username.indexOf('\\');
+        if (username != null) {
+            ci = username.indexOf('@');
             if (ci > 0) {
-                domain = username.substring(0, ci);
-                username = username.substring(ci + 1);
+                domain = username.substring(ci + 1);
+                username = username.substring(0, ci);
+            } else {
+                ci = username.indexOf('\\');
+                if (ci > 0) {
+                    domain = username.substring(0, ci);
+                    username = username.substring(ci + 1);
+                }
             }
         }
 
index 10c57fc..c185c0b 100644 (file)
@@ -15,6 +15,7 @@ interface SmbConstants {
     static final int DEFAULT_RCV_BUF_SIZE = 60416;
     static final int DEFAULT_SND_BUF_SIZE = 16644;
     static final int DEFAULT_SSN_LIMIT = 250;
+    static final int DEFAULT_CONN_TIMEOUT = 35000;
 
     static final InetAddress LADDR = Config.getLocalHost();
     static final int LPORT = Config.getInt( "jcifs.smb.client.lport", 0 );
@@ -152,6 +153,8 @@ interface SmbConstants {
             Config.getInt( "jcifs.smb.client.ssnLimit", DEFAULT_SSN_LIMIT );
     static final int SO_TIMEOUT =
             Config.getInt( "jcifs.smb.client.soTimeout", DEFAULT_SO_TIMEOUT );
+    static final int CONN_TIMEOUT =
+            Config.getInt( "jcifs.smb.client.connTimeout", DEFAULT_CONN_TIMEOUT );
     static final String NATIVE_OS =
             Config.getProperty( "jcifs.smb.client.nativeOs", System.getProperty( "os.name" ));
     static final String NATIVE_LANMAN =
index 2e6c22b..8dcbe2d 100644 (file)
@@ -193,7 +193,8 @@ public class SmbTransport extends Transport implements SmbConstants {
             socket = new Socket();
             if (localAddr != null)
                 socket.bind(new InetSocketAddress(localAddr, localPort));
-            socket.connect(new InetSocketAddress(address.getHostAddress(), 139), SO_TIMEOUT);
+            socket.connect(new InetSocketAddress(address.getHostAddress(), 139), CONN_TIMEOUT);
+            socket.setSoTimeout( SO_TIMEOUT );
 
             out = socket.getOutputStream();
             in = socket.getInputStream();
@@ -260,7 +261,8 @@ public class SmbTransport extends Transport implements SmbConstants {
                 socket = new Socket();
                 if (localAddr != null)
                     socket.bind(new InetSocketAddress(localAddr, localPort));
-                socket.connect(new InetSocketAddress(address.getHostAddress(), port), SO_TIMEOUT);
+                socket.connect(new InetSocketAddress(address.getHostAddress(), port), CONN_TIMEOUT);
+                socket.setSoTimeout( SO_TIMEOUT );
 
                 out = socket.getOutputStream();
                 in = socket.getInputStream();