From: Felix Schumacher Date: Wed, 6 Aug 2008 14:24:30 +0000 (+0200) Subject: jcifs-1.1.2 from tgz X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=17ad8b5fc5e8a5f59c1427547846d66ee24bf9e0;p=jcifs_without_docs.git jcifs-1.1.2 from tgz Sun Oct 31 00:58:04 EDT 2004 jcifs-1.1.1 released The jcifs.smb.client.logonShare (and thus the JCIFSACL NTLM HTTP Filter example) did not work. It would not restrict users to those found in the ACL it would permit all authenticated users. This has been fixed. A bug was discovered and fixed in the named pipe code. If a specific sequence of reads were performed the pipe could become corrupted. This fix is necessary for multi-pdu DCE requests to work. A small bug in the new NbtAddress.getAllByName method has been repaired. It will now broadcast for a name if a WINS address was not provided. --- diff --git a/README.txt b/README.txt index 5eb970e..937172a 100644 --- a/README.txt +++ b/README.txt @@ -1,9 +1,16 @@ -Thu Oct 21 19:20:04 EDT 2004 +Sun Oct 31 00:58:04 EDT 2004 jcifs-1.1.1 released -A bug was discovered and fixed in the named pipe code. If a specific sequence of reads were performed the pipe could become corrupted. This fix is necessary for multi-pdu DCE requests to work. +The jcifs.smb.client.logonShare (and thus the JCIFSACL NTLM HTTP Filter +example) did not work. It would not restrict users to those found in the +ACL it would permit all authenticated users. This has been fixed. -A small bug in the new NbtAddress.getAllByName method has been repaired. It will now broadcast for a name if a WINS address was not provided. +A bug was discovered and fixed in the named pipe code. If a specific +sequence of reads were performed the pipe could become corrupted. This fix +is necessary for multi-pdu DCE requests to work. + +A small bug in the new NbtAddress.getAllByName method has been repaired. It +will now broadcast for a name if a WINS address was not provided. jcifs-1.1.0 released diff --git a/build.xml b/build.xml index 77cacc2..fe319db 100644 --- a/build.xml +++ b/build.xml @@ -1,7 +1,7 @@ - - + + diff --git a/examples/ListDC.java b/examples/ListDC.java index 191f384..b0ad0f2 100644 --- a/examples/ListDC.java +++ b/examples/ListDC.java @@ -4,10 +4,10 @@ public class ListDC { public static void main( String argv[] ) throws Exception { - NbtAddress[] addrs = NbtAddress.getAllByName( argv[0], 0x1C, null, null ); + NbtAddress[] addrs = NbtAddress.getAllByName( argv[0], 0x1C, null, null ); - for( int i = 0; i < addrs.length; i++ ) { - System.out.println( addrs[i] ); - } + for( int i = 0; i < addrs.length; i++ ) { + System.out.println( addrs[i] ); + } } } diff --git a/examples/Logon.java b/examples/Logon.java index 334521b..1088434 100644 --- a/examples/Logon.java +++ b/examples/Logon.java @@ -3,13 +3,13 @@ import jcifs.smb.*; public class Logon { - /* java Logon 192.168.1.15 "dom;user:pass" - */ + /* java Logon 192.168.1.15 "dom;user:pass" + */ public static void main( String argv[] ) throws Exception { - UniAddress dc = UniAddress.getByName( argv[0] ); - NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication( argv[1] ); - SmbSession.logon( dc, auth ); + UniAddress dc = UniAddress.getByName( argv[0] ); + NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication( argv[1] ); + SmbSession.logon( dc, auth ); } } diff --git a/examples/runtests.sh b/examples/runtests.sh old mode 100755 new mode 100644 diff --git a/jcifsacl.prp b/jcifsacl.prp deleted file mode 100644 index d5a63e9..0000000 --- a/jcifsacl.prp +++ /dev/null @@ -1 +0,0 @@ -jcifs.smb.client.logonShare = JCIFSACL diff --git a/src/jcifs/http/NtlmHttpFilter.java b/src/jcifs/http/NtlmHttpFilter.java index 6881805..3ecad04 100644 --- a/src/jcifs/http/NtlmHttpFilter.java +++ b/src/jcifs/http/NtlmHttpFilter.java @@ -115,26 +115,26 @@ public class NtlmHttpFilter implements Filter { (offerBasic && msg.startsWith("Basic ")))) { if (msg.startsWith("NTLM ")) { HttpSession ssn = req.getSession(); - byte[] challenge; - - if( loadBalance ) { - NtlmChallenge chal = (NtlmChallenge)ssn.getAttribute( "NtlmHttpChal" ); - if( chal == null ) { - chal = SmbSession.getChallengeForDomain(); - ssn.setAttribute( "NtlmHttpChal", chal ); - } - dc = chal.dc; - challenge = chal.challenge; - } else { - dc = UniAddress.getByName( domainController, true ); - challenge = SmbSession.getChallenge( dc ); - } + byte[] challenge; + + if( loadBalance ) { + NtlmChallenge chal = (NtlmChallenge)ssn.getAttribute( "NtlmHttpChal" ); + if( chal == null ) { + chal = SmbSession.getChallengeForDomain(); + ssn.setAttribute( "NtlmHttpChal", chal ); + } + dc = chal.dc; + challenge = chal.challenge; + } else { + dc = UniAddress.getByName( domainController, true ); + challenge = SmbSession.getChallenge( dc ); + } if(( ntlm = NtlmSsp.authenticate( req, resp, challenge )) == null ) { return; } /* negotiation complete, remove the challenge object */ - ssn.removeAttribute( "NtlmHttpChal" ); + ssn.removeAttribute( "NtlmHttpChal" ); } else { String auth = new String(Base64.decode(msg.substring(6)), "US-ASCII"); @@ -148,7 +148,7 @@ public class NtlmHttpFilter implements Filter { defaultDomain; user = (index != -1) ? user.substring(index + 1) : user; ntlm = new NtlmPasswordAuthentication(domain, user, password); - dc = UniAddress.getByName( domainController, true ); + dc = UniAddress.getByName( domainController, true ); } try { diff --git a/src/jcifs/netbios/NameQueryResponse.java b/src/jcifs/netbios/NameQueryResponse.java index d8d8f27..693e0e9 100644 --- a/src/jcifs/netbios/NameQueryResponse.java +++ b/src/jcifs/netbios/NameQueryResponse.java @@ -41,11 +41,11 @@ class NameQueryResponse extends NameServicePacket { int nodeType = ( src[srcIndex] & 0x60 ) >> 5; srcIndex += 2; int address = readInt4( src, srcIndex ); - if( address != 0 ) { - addrEntry[addrIndex] = new NbtAddress( recordName, address, groupName, nodeType ); - } else { - addrEntry[addrIndex] = null; - } + if( address != 0 ) { + addrEntry[addrIndex] = new NbtAddress( recordName, address, groupName, nodeType ); + } else { + addrEntry[addrIndex] = null; + } return 6; } diff --git a/src/jcifs/netbios/NameServiceClient.java b/src/jcifs/netbios/NameServiceClient.java index 56bf06a..2490752 100644 --- a/src/jcifs/netbios/NameServiceClient.java +++ b/src/jcifs/netbios/NameServiceClient.java @@ -258,20 +258,20 @@ class NameServiceClient implements Runnable { NbtAddress[] getAllByName( Name name, InetAddress addr ) throws UnknownHostException { - int n; + int n; NameQueryRequest request = new NameQueryRequest( name ); NameQueryResponse response = new NameQueryResponse(); - request.addr = addr != null ? addr : NbtAddress.getWINSAddress(); - request.isBroadcast = request.addr == null; + request.addr = addr != null ? addr : NbtAddress.getWINSAddress(); + request.isBroadcast = request.addr == null; - if( request.isBroadcast ) { + if( request.isBroadcast ) { request.addr = baddr; n = RETRY_COUNT; - } else { - request.isBroadcast = false; - n = 1; - } + } else { + request.isBroadcast = false; + n = 1; + } do { try { @@ -288,7 +288,7 @@ class NameServiceClient implements Runnable { } while( --n > 0 && request.isBroadcast ); throw new UnknownHostException( name.name ); - } + } NbtAddress getByName( Name name, InetAddress addr ) throws UnknownHostException { int n; diff --git a/src/jcifs/netbios/NameServicePacket.java b/src/jcifs/netbios/NameServicePacket.java index 32ce331..38b7d47 100644 --- a/src/jcifs/netbios/NameServicePacket.java +++ b/src/jcifs/netbios/NameServicePacket.java @@ -220,8 +220,8 @@ abstract class NameServicePacket { rDataLength = readInt2( src, srcIndex ); srcIndex += 2; - addrEntry = new NbtAddress[rDataLength / 6]; - end = srcIndex + rDataLength; + addrEntry = new NbtAddress[rDataLength / 6]; + end = srcIndex + rDataLength; for( addrIndex = 0; srcIndex < end; addrIndex++ ) { srcIndex += readRDataWireFormat( src, srcIndex ); } diff --git a/src/jcifs/netbios/NbtAddress.java b/src/jcifs/netbios/NbtAddress.java index 806a462..cbff6e3 100644 --- a/src/jcifs/netbios/NbtAddress.java +++ b/src/jcifs/netbios/NbtAddress.java @@ -443,13 +443,13 @@ public final class NbtAddress { } } - public static NbtAddress[] getAllByName( String host, + public static NbtAddress[] getAllByName( String host, int type, String scope, InetAddress svr ) throws UnknownHostException { - return CLIENT.getAllByName( new Name( host, type, scope ), svr ); - } + return CLIENT.getAllByName( new Name( host, type, scope ), svr ); + } /** * Retrieve all addresses of a host by it's address. NetBIOS hosts can diff --git a/src/jcifs/smb/DosFileFilter.java b/src/jcifs/smb/DosFileFilter.java index 4c1be77..a9514f3 100644 --- a/src/jcifs/smb/DosFileFilter.java +++ b/src/jcifs/smb/DosFileFilter.java @@ -40,6 +40,6 @@ public class DosFileFilter implements SmbFileFilter { * specified the server may still return objects that are not directories). */ public boolean accept( SmbFile file ) throws SmbException { - return (file.getAttributes() & attributes) != 0; + return (file.getAttributes() & attributes) != 0; } } diff --git a/src/jcifs/smb/NtlmChallenge.java b/src/jcifs/smb/NtlmChallenge.java index e6f44f8..c5c0874 100644 --- a/src/jcifs/smb/NtlmChallenge.java +++ b/src/jcifs/smb/NtlmChallenge.java @@ -23,17 +23,17 @@ import jcifs.util.Hexdump; public final class NtlmChallenge { - public byte[] challenge; - public UniAddress dc; + public byte[] challenge; + public UniAddress dc; - NtlmChallenge( byte[] challenge, UniAddress dc ) { - this.challenge = challenge; - this.dc = dc; - } + NtlmChallenge( byte[] challenge, UniAddress dc ) { + this.challenge = challenge; + this.dc = dc; + } - public String toString() { - return "NtlmChallenge[challenge=0x" + - Hexdump.toHexString( challenge, 0, challenge.length * 2 ) + - ",dc=" + dc.toString() + "]"; - } + public String toString() { + return "NtlmChallenge[challenge=0x" + + Hexdump.toHexString( challenge, 0, challenge.length * 2 ) + + ",dc=" + dc.toString() + "]"; + } } diff --git a/src/jcifs/smb/SmbComNTCreateAndX.java b/src/jcifs/smb/SmbComNTCreateAndX.java index d31b57d..e908da3 100644 --- a/src/jcifs/smb/SmbComNTCreateAndX.java +++ b/src/jcifs/smb/SmbComNTCreateAndX.java @@ -116,8 +116,6 @@ class SmbComNTCreateAndX extends AndXServerMessageBlock { // desiredAccess desiredAccess = ( flags >>> 16 ) & 0xFFFF; -System.out.println( "desiredAccess: 0x" + jcifs.util.Hexdump.toHexString( desiredAccess, 8 )); -if (desiredAccess == 0) throw new RuntimeException(); desiredAccess |= FILE_READ_EA | FILE_READ_ATTRIBUTES; // extFileAttributes diff --git a/src/jcifs/smb/SmbSession.java b/src/jcifs/smb/SmbSession.java index 0b14cf7..a796c57 100644 --- a/src/jcifs/smb/SmbSession.java +++ b/src/jcifs/smb/SmbSession.java @@ -54,73 +54,73 @@ public final class SmbSession { private static final String LOGON_SHARE = Config.getProperty( "jcifs.smb.client.logonShare", null ); private static final int LOOKUP_RESP_LIMIT = jcifs.Config.getInt( "jcifs.netbios.lookupRespLimit", 5 ); - private static final String DOMAIN = Config.getProperty("jcifs.smb.client.domain", null); - private static final String USERNAME = Config.getProperty("jcifs.smb.client.username", null); + private static final String DOMAIN = Config.getProperty("jcifs.smb.client.domain", null); + private static final String USERNAME = Config.getProperty("jcifs.smb.client.username", null); private static final int DEFAULT_CACHE_POLICY = 30; private static final int CACHE_POLICY = Config.getInt( "jcifs.netbios.cachePolicy", DEFAULT_CACHE_POLICY ); - static long dc_list_expiration; - static NbtAddress[] dc_list = null; - static int dc_list_index; /* always less than dc_list_range */ - static int dc_list_range = 1; /* always less than LOOKUP_RESP_LIMIT */ - - static void incr_dc_list_range() { - if( dc_list_range < LOOKUP_RESP_LIMIT && - dc_list_range < dc_list.length ) { - dc_list_range++; - } - } - public static NtlmChallenge getChallengeForDomain() - throws SmbException, UnknownHostException { - int starting_index; - - if( DOMAIN == null ) { - throw new SmbException( "A domain was not specified" ); - } + static long dc_list_expiration; + static NbtAddress[] dc_list = null; + static int dc_list_index; /* always less than dc_list_range */ + static int dc_list_range = 1; /* always less than LOOKUP_RESP_LIMIT */ + + static void incr_dc_list_range() { + if( dc_list_range < LOOKUP_RESP_LIMIT && + dc_list_range < dc_list.length ) { + dc_list_range++; + } + } + public static NtlmChallenge getChallengeForDomain() + throws SmbException, UnknownHostException { + int starting_index; + + if( DOMAIN == null ) { + throw new SmbException( "A domain was not specified" ); + } synchronized( DOMAIN ) { - if( dc_list_expiration < System.currentTimeMillis() ) { - dc_list = NbtAddress.getAllByName( DOMAIN, 0x1C, null, null ); - dc_list_expiration = System.currentTimeMillis() + CACHE_POLICY * 1000L; - if( dc_list_range > 1 ) { - dc_list_range /= 2; /* shrink dc_list_range */ - } - } - - starting_index = dc_list_index; - do { - if( dc_list_index == dc_list_range ) { - dc_list_index = 0; - } - NbtAddress addr = dc_list[dc_list_index]; - if( addr != null ) { - try { - UniAddress dc = new UniAddress( addr ); - SmbTransport trans = SmbTransport.getSmbTransport( dc, 0 ); - if( USERNAME == null ) { - if( SmbTransport.log.level > 1 ) - SmbTransport.log.println( "Default credentials (jcifs.smb.client.username/password) not specified. SMB signing may not work propertly. Skipping DC interrogation." ); - trans.negotiate(); - } else { - trans.getSmbSession( NtlmPasswordAuthentication.DEFAULT ).getSmbTree( LOGON_SHARE, null ).treeConnect( null, null ); - } - if( trans.sessions.size() > (trans.SSN_LIMIT / 10)) { - incr_dc_list_range(); - } - dc_list_index++; - return new NtlmChallenge( trans.server.encryptionKey, dc ); - } catch( SmbException se ) { - if( SmbTransport.log.level > 1 ) - SmbTransport.log.println( "Failed validate DC: " + addr + ": " + se.getMessage() ); - } - dc_list[dc_list_index] = null; /* dc no good */ - incr_dc_list_range(); - } - dc_list_index++; - } while( dc_list_index != starting_index ); + if( dc_list_expiration < System.currentTimeMillis() ) { + dc_list = NbtAddress.getAllByName( DOMAIN, 0x1C, null, null ); + dc_list_expiration = System.currentTimeMillis() + CACHE_POLICY * 1000L; + if( dc_list_range > 1 ) { + dc_list_range /= 2; /* shrink dc_list_range */ + } + } + + starting_index = dc_list_index; + do { + if( dc_list_index == dc_list_range ) { + dc_list_index = 0; + } + NbtAddress addr = dc_list[dc_list_index]; + if( addr != null ) { + try { + UniAddress dc = new UniAddress( addr ); + SmbTransport trans = SmbTransport.getSmbTransport( dc, 0 ); + if( USERNAME == null ) { + if( SmbTransport.log.level > 1 ) + SmbTransport.log.println( "Default credentials (jcifs.smb.client.username/password) not specified. SMB signing may not work propertly. Skipping DC interrogation." ); + trans.negotiate(); + } else { + trans.getSmbSession( NtlmPasswordAuthentication.DEFAULT ).getSmbTree( LOGON_SHARE, null ).treeConnect( null, null ); + } + if( trans.sessions.size() > (trans.SSN_LIMIT / 10)) { + incr_dc_list_range(); + } + dc_list_index++; + return new NtlmChallenge( trans.server.encryptionKey, dc ); + } catch( SmbException se ) { + if( SmbTransport.log.level > 1 ) + SmbTransport.log.println( "Failed validate DC: " + addr + ": " + se.getMessage() ); + } + dc_list[dc_list_index] = null; /* dc no good */ + incr_dc_list_range(); + } + dc_list_index++; + } while( dc_list_index != starting_index ); } - throw new UnknownHostException( "Failed to negotiate with a suitable domain controller for " + DOMAIN ); - } + throw new UnknownHostException( "Failed to negotiate with a suitable domain controller for " + DOMAIN ); + } public static byte[] getChallenge( UniAddress dc ) @@ -152,14 +152,14 @@ synchronized( DOMAIN ) { public static void logon( UniAddress dc, int port, NtlmPasswordAuthentication auth ) throws SmbException { - SmbTree tree = SmbTransport.getSmbTransport( dc, port ).getSmbSession( auth ).getSmbTree( LOGON_SHARE, null ); - if( LOGON_SHARE == null ) { - tree.treeConnect( null, null ); - } else { - Trans2FindFirst2 req = new Trans2FindFirst2( "\\", "*", SmbFile.ATTR_DIRECTORY ); - Trans2FindFirst2Response resp = new Trans2FindFirst2Response(); + SmbTree tree = SmbTransport.getSmbTransport( dc, port ).getSmbSession( auth ).getSmbTree( LOGON_SHARE, null ); + if( LOGON_SHARE == null ) { + tree.treeConnect( null, null ); + } else { + Trans2FindFirst2 req = new Trans2FindFirst2( "\\", "*", SmbFile.ATTR_DIRECTORY ); + Trans2FindFirst2Response resp = new Trans2FindFirst2Response(); tree.sendTransaction( req, resp ); - } + } } private int uid; @@ -172,7 +172,7 @@ synchronized( DOMAIN ) { SmbTransport transport = SmbTransport.NULL_TRANSPORT; NtlmPasswordAuthentication auth; - long expiration; + long expiration; SmbSession( UniAddress address, int port, InetAddress localAddr, int localPort, @@ -234,7 +234,7 @@ synchronized( DOMAIN ) { void sessionSetup( ServerMessageBlock andx, ServerMessageBlock andxResponse ) throws SmbException { - expiration = System.currentTimeMillis() + SmbTransport.SO_TIMEOUT; + expiration = System.currentTimeMillis() + SmbTransport.SO_TIMEOUT; synchronized( transport() ) { if( sessionSetup ) { diff --git a/src/jcifs/smb/SmbTransport.java b/src/jcifs/smb/SmbTransport.java index 0a45299..19d0529 100644 --- a/src/jcifs/smb/SmbTransport.java +++ b/src/jcifs/smb/SmbTransport.java @@ -107,13 +107,13 @@ private static byte[] rcv_buf = new byte[0xFFFF]; private LinkedList referrals = new LinkedList(); private Mid[] mids = new Mid[MAX_MPX_COUNT]; private short mid_next; - private IOException socketException; - private long sessionExpiration = System.currentTimeMillis() + SO_TIMEOUT; + private IOException socketException; + private long sessionExpiration = System.currentTimeMillis() + SO_TIMEOUT; static final int SSN_LIMIT = - Config.getInt( "jcifs.smb.client.ssnLimit", DEFAULT_SSN_LIMIT ); + Config.getInt( "jcifs.smb.client.ssnLimit", DEFAULT_SSN_LIMIT ); static final int SO_TIMEOUT = - Config.getInt( "jcifs.smb.client.soTimeout", DEFAULT_SO_TIMEOUT ); + Config.getInt( "jcifs.smb.client.soTimeout", DEFAULT_SO_TIMEOUT ); static final String NATIVE_OS = Config.getProperty( "jcifs.smb.client.nativeOs", System.getProperty( "os.name" )); static final String NATIVE_LANMAN = @@ -223,22 +223,22 @@ private static byte[] rcv_buf = new byte[0xFFFF]; if( ssn.matches( auth )) { ssn.auth = auth; return ssn; - } - } - - /* close old sessions */ - long now = System.currentTimeMillis(); - if( sessionExpiration < now ) { - sessionExpiration = now + SO_TIMEOUT; - iter = sessions.listIterator(); - while( iter.hasNext() ) { - ssn = (SmbSession)iter.next(); - if( ssn.expiration < now ) { - ssn.logoff( false ); - sessions.remove( ssn ); - } - } - } + } + } + + /* close old sessions */ + long now = System.currentTimeMillis(); + if( sessionExpiration < now ) { + sessionExpiration = now + SO_TIMEOUT; + iter = sessions.listIterator(); + while( iter.hasNext() ) { + ssn = (SmbSession)iter.next(); + if( ssn.expiration < now ) { + ssn.logoff( false ); + sessions.remove( ssn ); + } + } + } ssn = new SmbSession( address, port, localAddr, localPort, auth ); ssn.transport = this; @@ -305,28 +305,28 @@ private static byte[] rcv_buf = new byte[0xFFFF]; state = ST_GROUND; } void start() throws SmbException { - try { - thread = new Thread( this, "JCIFS-SmbTransport" ); - thread.setDaemon( true ); - thread.start(); - - wait( RESPONSE_TIMEOUT ); /* wait for the thread to be started and socket opened */ - - if( socket == null ) { /* failed to open socket for some reason */ - tryClose( true ); - throw new SmbException( "Timeout trying to open socket (probably no ACK to SYN) for address", socketException ); - } - } catch( InterruptedException ie ) { - tryClose( true ); - throw new SmbException( "Interrupted opening socket", ie ); - } + try { + thread = new Thread( this, "JCIFS-SmbTransport" ); + thread.setDaemon( true ); + thread.start(); + + wait( RESPONSE_TIMEOUT ); /* wait for the thread to be started and socket opened */ + + if( socket == null ) { /* failed to open socket for some reason */ + tryClose( true ); + throw new SmbException( "Timeout trying to open socket (probably no ACK to SYN) for address", socketException ); + } + } catch( InterruptedException ie ) { + tryClose( true ); + throw new SmbException( "Interrupted opening socket", ie ); + } } public void run() { Mid mid = new Mid(); int i, m, nbtlen; ServerMessageBlock response; - try { + try { Object obj; NbtAddress naddr; String calledName; @@ -346,19 +346,19 @@ private static byte[] rcv_buf = new byte[0xFFFF]; do { try { socket = new NbtSocket( naddr, calledName, port, localAddr, localPort ); - if( TCP_NODELAY ) { - socket.setTcpNoDelay( true ); - } - socket.setSoTimeout( SO_TIMEOUT ); - in = new PushbackInputStream( socket.getInputStream(), PUSHBACK_BUF_SIZE ); - out = socket.getOutputStream(); + if( TCP_NODELAY ) { + socket.setTcpNoDelay( true ); + } + socket.setSoTimeout( SO_TIMEOUT ); + in = new PushbackInputStream( socket.getInputStream(), PUSHBACK_BUF_SIZE ); + out = socket.getOutputStream(); break; } catch( NbtException ne ) { if( ne.errorClass == NbtException.ERR_SSN_SRVC && ( ne.errorCode == NbtException.CALLED_NOT_PRESENT || ne.errorCode == NbtException.NOT_LISTENING_CALLED )) { - if( log.level > 2 ) - ne.printStackTrace( log ); + if( log.level > 2 ) + ne.printStackTrace( log ); } else { throw ne; } @@ -376,15 +376,15 @@ private static byte[] rcv_buf = new byte[0xFFFF]; } else { tconHostName = calledName; } - } catch( IOException ioe ) { - socketException = ioe; + } catch( IOException ioe ) { + socketException = ioe; if( log.level > 1 ) ioe.printStackTrace( log ); - return; - } finally { - synchronized( this ) { - notifyAll(); - } + return; + } finally { + synchronized( this ) { + notifyAll(); + } } while( thread == Thread.currentThread() ) { @@ -584,8 +584,8 @@ synchronized( rcv_buf ) { ServerMessageBlock response ) throws SmbException { Mid mid = null; - if( request.command != request.SMB_COM_NEGOTIATE ) - negotiate(); + if( request.command != request.SMB_COM_NEGOTIATE ) + negotiate(); request.flags2 |= flags2; request.useUnicode = useUnicode; @@ -708,7 +708,7 @@ synchronized( snd_buf ) { SmbComTransactionResponse response ) throws SmbException { Mid mid = null; - negotiate(); + negotiate(); request.flags2 |= flags2; request.useUnicode = useUnicode; @@ -863,29 +863,29 @@ synchronized( snd_buf ) { DfsReferral dr = getDfsReferral( request.auth, request.path ); referrals.add( dr ); throw dr; - case 0x80000005: - break; + case 0x80000005: + break; default: throw new SmbException( response.errorCode, null ); } } synchronized void negotiate() throws SmbException { - if( state == ST_GROUND ) { - state = ST_NEGOTIATING; - } else { - while( state != ST_NEGOTIATED ) { - try { - wait(); - } catch( InterruptedException ie ) { - tryClose( true ); - throw new SmbException( "Interrupted opening socket", ie ); - } - } - return; - } - - start(); /* start the transport thread (which opens the socket) */ + if( state == ST_GROUND ) { + state = ST_NEGOTIATING; + } else { + while( state != ST_NEGOTIATED ) { + try { + wait(); + } catch( InterruptedException ie ) { + tryClose( true ); + throw new SmbException( "Interrupted opening socket", ie ); + } + } + return; + } + + start(); /* start the transport thread (which opens the socket) */ if( this == NULL_TRANSPORT ) { throw new RuntimeException( "Null transport cannot be used" ); @@ -946,7 +946,7 @@ synchronized( snd_buf ) { } } - state = ST_NEGOTIATED; + state = ST_NEGOTIATED; } public String toString() { String ret = "SmbTransport[address=" + address; diff --git a/src/jcifs/smb/TransactNamedPipeInputStream.java b/src/jcifs/smb/TransactNamedPipeInputStream.java index 68f28b2..0a0285e 100644 --- a/src/jcifs/smb/TransactNamedPipeInputStream.java +++ b/src/jcifs/smb/TransactNamedPipeInputStream.java @@ -29,13 +29,13 @@ class TransactNamedPipeInputStream extends SmbFileInputStream { private byte[] pipe_buf = new byte[INIT_PIPE_SIZE]; private int beg_idx, nxt_idx, used; - private boolean dcePipe; + private boolean dcePipe; Object lock; TransactNamedPipeInputStream( SmbNamedPipe pipe ) throws SmbException, MalformedURLException, UnknownHostException { - super( pipe, ( pipe.pipeType & 0xFFFF0000 ) | SmbFile.O_EXCL ); - this.dcePipe = ( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT ) == SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT; + super( pipe, ( pipe.pipeType & 0xFFFF0000 ) | SmbFile.O_EXCL ); + this.dcePipe = ( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT ) == SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT; lock = new Object(); } public int read() throws IOException { @@ -130,6 +130,6 @@ class TransactNamedPipeInputStream extends SmbFileInputStream { return len; } public int dce_read( byte[] b, int off, int len ) throws IOException { - return super.read(b, off, len); - } + return super.read(b, off, len); + } } diff --git a/src/jcifs/smb/TransactNamedPipeOutputStream.java b/src/jcifs/smb/TransactNamedPipeOutputStream.java index 03890db..9f1bbbd 100644 --- a/src/jcifs/smb/TransactNamedPipeOutputStream.java +++ b/src/jcifs/smb/TransactNamedPipeOutputStream.java @@ -26,11 +26,11 @@ class TransactNamedPipeOutputStream extends OutputStream { private String path; private SmbNamedPipe pipe; private byte[] tmp = new byte[1]; - private boolean dcePipe; + private boolean dcePipe; TransactNamedPipeOutputStream( SmbNamedPipe pipe ) throws IOException { this.pipe = pipe; - this.dcePipe = ( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT ) == SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT; + this.dcePipe = ( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT ) == SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT; path = pipe.unc; } @@ -58,10 +58,10 @@ class TransactNamedPipeOutputStream extends OutputStream { } else if(( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_TRANSACT ) == SmbNamedPipe.PIPE_TYPE_TRANSACT ) { pipe.open(( pipe.pipeType & 0xFFFF0000 ) | SmbFile.O_EXCL, SmbFile.ATTR_NORMAL, 0 ); - TransTransactNamedPipe req = new TransTransactNamedPipe( pipe.fid, b, off, len ); - if (dcePipe) { - req.maxDataCount = 1024; - } + TransTransactNamedPipe req = new TransTransactNamedPipe( pipe.fid, b, off, len ); + if (dcePipe) { + req.maxDataCount = 1024; + } pipe.sendTransaction( req, new TransTransactNamedPipeResponse( pipe )); } } diff --git a/src/jcifs/util/Encdec.java b/src/jcifs/util/Encdec.java index 97f071d..9d7979d 100644 --- a/src/jcifs/util/Encdec.java +++ b/src/jcifs/util/Encdec.java @@ -300,15 +300,15 @@ public class Encdec { return new String( uni, 0, ui ); } public static String dec_ucs2le( byte[] src, int si, int slim, char[] buf ) throws IOException { - int bi; + int bi; - for( bi = 0; (si + 1) < slim; bi++, si += 2 ) { - buf[bi] = (char)dec_uint16le( src, si ); - if( buf[bi] == '\0' ) { - break; - } - } + for( bi = 0; (si + 1) < slim; bi++, si += 2 ) { + buf[bi] = (char)dec_uint16le( src, si ); + if( buf[bi] == '\0' ) { + break; + } + } - return new String( buf, 0, bi ); - } + return new String( buf, 0, bi ); + } }