jcifs-1.1.6 from tgz
authorFelix Schumacher <p0354740@isib001.(none)>
Wed, 6 Aug 2008 14:27:05 +0000 (16:27 +0200)
committerFelix Schumacher <p0354740@isib001.(none)>
Wed, 6 Aug 2008 14:27:05 +0000 (16:27 +0200)
Mon Dec 27 17:53:42 EST 2004
jcifs-1.1.6 released

If  a variable length 8 bit encodings such as Big5 is used the NTCreateAndX
command    could    fail.    This    bug    has    been    fixed.   If   an
SmbFile{Input,Output}Stream  was closed, a subsequent operation could cause
the  file to be reopened. This behavior is now blocked such that operations
performed   on  a  stream  after  it  has  been  closed  will  generate  an
IOException.  Some  transport  layer  synchronization  has been adjusted. A
getPrincipal  method  has  been  added  to  SmbFile  that  will  return the
NtlmPasswordAuthentication  object  used  to  create  the file or pipe. The
documentation has been updated regarding transparent NTLM authentication in
Mozilla, the available method of SmbFileInputStream.

README.txt
build.xml
src/jcifs/smb/SmbComNTCreateAndX.java
src/jcifs/smb/SmbFile.java
src/jcifs/smb/SmbFileInputStream.java
src/jcifs/smb/SmbFileOutputStream.java
src/jcifs/smb/SmbTransport.java

index bb7ee7d..d6713c8 100644 (file)
@@ -1,3 +1,17 @@
+Mon Dec 27 17:53:42 EST 2004
+jcifs-1.1.6 released
+
+If  a variable length 8 bit encodings such as Big5 is used the NTCreateAndX
+command    could    fail.    This    bug    has    been    fixed.   If   an
+SmbFile{Input,Output}Stream  was closed, a subsequent operation could cause
+the  file to be reopened. This behavior is now blocked such that operations
+performed   on  a  stream  after  it  has  been  closed  will  generate  an
+IOException.  Some  transport  layer  synchronization  has been adjusted. A
+getPrincipal  method  has  been  added  to  SmbFile  that  will  return the
+NtlmPasswordAuthentication  object  used  to  create  the file or pipe. The
+documentation has been updated regarding transparent NTLM authentication in
+Mozilla, the available method of SmbFileInputStream. 
+
 Thu Dec 16 21:57:23 EST 2004
 jcifs-1.1.5 released
 
index a620562..0715361 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -1,7 +1,7 @@
 <project name="jcifs" default="usage" basedir=".">
 
-    <property name="version" value="1.1.5"/>
-    <property name="reldate" value="Dec 17, 2004"/>
+    <property name="version" value="1.1.6"/>
+    <property name="reldate" value="Dec 27, 2004"/>
 
     <target name="usage">
         <echo>
index e908da3..d8779f5 100644 (file)
@@ -104,6 +104,7 @@ class SmbComNTCreateAndX extends AndXServerMessageBlock {
         impersonationLevel;
     private long allocationSize;
     private byte securityFlags;
+    private int namelen_index;
 
     SmbComNTCreateAndX( String name, int flags,
                 int shareAccess,
@@ -162,7 +163,7 @@ class SmbComNTCreateAndX extends AndXServerMessageBlock {
 
         dst[dstIndex++] = (byte)0x00;
         // name length without counting null termination
-        writeInt2( ( useUnicode ? path.length() * 2 : path.length() ), dst, dstIndex );
+        namelen_index = dstIndex;
         dstIndex += 2;
         writeInt4( flags, dst, dstIndex );
         dstIndex += 4;
@@ -187,7 +188,10 @@ class SmbComNTCreateAndX extends AndXServerMessageBlock {
         return dstIndex - start;
     }
     int writeBytesWireFormat( byte[] dst, int dstIndex ) {
-        return writeString( path, dst, dstIndex );
+        int n;
+        n = writeString( path, dst, dstIndex );
+        writeInt2( ( useUnicode ? path.length() * 2 : n ), dst, namelen_index );
+        return n;
     }
     int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) {
         return 0;
index 925964b..6615e46 100644 (file)
@@ -26,6 +26,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
+import java.security.Principal;
 import jcifs.Config;
 import jcifs.util.LogStream;
 import jcifs.UniAddress;
@@ -906,6 +907,22 @@ public class SmbFile extends URLConnection {
     }
 
 /**
+ * Returns the <tt>NtlmPasswordAuthentication</tt> object used as
+ * credentials with this file or pipe. This can be used to retrieve the
+ * username for example:
+ * <tt>
+ * String username = f.getPrincipal().getName();
+ * </tt>
+ * The <tt>Principal</tt> object returned will never be <tt>null</tt>
+ * however the username can be <tt>null</tt> indication anonymous
+ * credentials were used (e.g. some IPC$ services).
+ */
+
+    public Principal getPrincipal() {
+        return auth;
+    }
+
+/**
  * Returns the last component of the target URL. This will
  * effectively be the name of the file or directory represented by this
  * <code>SmbFile</code> or in the case of URLs that only specify a server
index 78cfcbc..626812a 100644 (file)
@@ -80,6 +80,7 @@ public class SmbFileInputStream extends InputStream {
 
     public void close() throws IOException {
         file.close();
+        tmp = null;
     }
 
 /**
@@ -118,6 +119,9 @@ public class SmbFileInputStream extends InputStream {
         }
         long start = fp;
 
+        if( tmp == null ) {
+            throw new IOException( "Bad file descriptor" );
+        }
         // ensure file is open
         file.open( openFlags, SmbFile.ATTR_NORMAL, 0 );
 
@@ -160,6 +164,13 @@ public class SmbFileInputStream extends InputStream {
 
         return (int)(fp - start);
     }
+/**
+ * This stream class is unbuffered. Therefore this method will always
+ * return 0 for streams connected to regular files. However, a 
+ * stream created from a Named Pipe this method will query the server using a
+ * "peek named pipe" operation and return the number of available bytes
+ * on the server.
+ */
     public int available() throws IOException {
         SmbNamedPipe pipe;
         TransPeekNamedPipe req;
index 18a3f9c..d1893f6 100644 (file)
@@ -160,6 +160,7 @@ write, and/or delete the file while the jCIFS user has the file open.
 
     public void close() throws IOException {
         file.close();
+        tmp = null;
     }
 
 /**
@@ -197,6 +198,9 @@ write, and/or delete the file while the jCIFS user has the file open.
             return;
         }
 
+        if( tmp == null ) {
+            throw new IOException( "Bad file descriptor" );
+        }
         // ensure file is open
         if( file.isOpen() == false ) {
             if( file instanceof SmbNamedPipe ) {
index c51a469..1e21ad1 100644 (file)
@@ -718,6 +718,9 @@ synchronized( snd_buf ) {
         response.isPrimary = true;
 
         try {
+            synchronized( outLock ) {
+                mid = aquireMid();
+            }
             request.txn_buf = BufferCache.getBuffer();
             response.txn_buf = BufferCache.getBuffer();
 
@@ -730,7 +733,6 @@ synchronized( snd_buf ) {
                 synchronized( interimResponse ) {
                     try {
                         synchronized( outLock ) {
-                            mid = aquireMid();
                             request.mid = mid.mid;
                             responseTable.put( mid, interimResponse );
 synchronized(snd_buf) {
@@ -739,7 +741,7 @@ synchronized(snd_buf) {
                             int length = request.writeWireFormat(snd_buf, 4);
                             out.write(snd_buf, 4, length);
                             out.flush();
-    
+
                             if( log.level > 3 ) {
                                 log.println( request );
                                 if( log.level > 5 ) {
@@ -748,7 +750,7 @@ synchronized(snd_buf) {
                             }
 }
                         }
-    
+   
                         interimResponse.wait( RESPONSE_TIMEOUT );
     
                         if( interimResponse.received == false ) {
@@ -780,9 +782,6 @@ synchronized(snd_buf) {
                         }
                     } finally {
                         responseTable.remove( mid );
-                        synchronized( outLock ) {
-                            releaseMid( mid );
-                        }
                     }
                 }
 
@@ -792,7 +791,6 @@ synchronized(snd_buf) {
             synchronized( response ) {
                 try {
                     synchronized( outLock ) {
-                        mid = aquireMid();
                         request.mid = mid.mid;
                         responseTable.put( mid, response );
                         do {
@@ -820,9 +818,6 @@ synchronized( snd_buf ) {
                     } while( response.received && response.hasMoreElements() );
                 } finally {
                     responseTable.remove( mid );
-                    synchronized( outLock ) {
-                        releaseMid( mid );
-                    }
                 }
             }
         } catch( InterruptedException ie ) {
@@ -831,6 +826,9 @@ synchronized( snd_buf ) {
             tryClose( true );
             throw new SmbException( "An error occured sending the request.", ioe );
         } finally {
+            synchronized( outLock ) {
+                releaseMid( mid );
+            }
             BufferCache.releaseBuffer( request.txn_buf );
             BufferCache.releaseBuffer( response.txn_buf );
         }