From: Felix Schumacher Date: Wed, 6 Aug 2008 14:27:05 +0000 (+0200) Subject: jcifs-1.1.6 from tgz X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a0936375cc01b90d21049ecaba19a8f54eed99f7;p=jcifs_without_docs.git jcifs-1.1.6 from tgz 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. --- diff --git a/README.txt b/README.txt index bb7ee7d..d6713c8 100644 --- a/README.txt +++ b/README.txt @@ -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 diff --git a/build.xml b/build.xml index a620562..0715361 100644 --- a/build.xml +++ b/build.xml @@ -1,7 +1,7 @@ - - + + diff --git a/src/jcifs/smb/SmbComNTCreateAndX.java b/src/jcifs/smb/SmbComNTCreateAndX.java index e908da3..d8779f5 100644 --- a/src/jcifs/smb/SmbComNTCreateAndX.java +++ b/src/jcifs/smb/SmbComNTCreateAndX.java @@ -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; diff --git a/src/jcifs/smb/SmbFile.java b/src/jcifs/smb/SmbFile.java index 925964b..6615e46 100644 --- a/src/jcifs/smb/SmbFile.java +++ b/src/jcifs/smb/SmbFile.java @@ -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 NtlmPasswordAuthentication object used as + * credentials with this file or pipe. This can be used to retrieve the + * username for example: + * + * String username = f.getPrincipal().getName(); + * + * The Principal object returned will never be null + * however the username can be null 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 * SmbFile or in the case of URLs that only specify a server diff --git a/src/jcifs/smb/SmbFileInputStream.java b/src/jcifs/smb/SmbFileInputStream.java index 78cfcbc..626812a 100644 --- a/src/jcifs/smb/SmbFileInputStream.java +++ b/src/jcifs/smb/SmbFileInputStream.java @@ -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; diff --git a/src/jcifs/smb/SmbFileOutputStream.java b/src/jcifs/smb/SmbFileOutputStream.java index 18a3f9c..d1893f6 100644 --- a/src/jcifs/smb/SmbFileOutputStream.java +++ b/src/jcifs/smb/SmbFileOutputStream.java @@ -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 ) { diff --git a/src/jcifs/smb/SmbTransport.java b/src/jcifs/smb/SmbTransport.java index c51a469..1e21ad1 100644 --- a/src/jcifs/smb/SmbTransport.java +++ b/src/jcifs/smb/SmbTransport.java @@ -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 ); }