+Thu Oct 21 19:20: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.
+
+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
The behavior of the firstCalledName/nextCalledName methods has been changed
<project name="jcifs" default="usage" basedir=".">
- <property name="version" value="1.1.0"/>
- <property name="reldate" value="Oct 1, 2004"/>
+ <property name="version" value="1.1.1p"/>
+ <property name="reldate" value="Oct 22, 2004"/>
<target name="usage">
<echo>
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] );
+ }
}
}
--- /dev/null
+import jcifs.*;
+import jcifs.smb.*;
+
+public class Logon {
+
+ /* 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 );
+ }
+}
+
--- /dev/null
+jcifs.smb.client.logonShare = JCIFSACL
(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");
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 {
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;
}
NbtAddress[] getAllByName( Name name, InetAddress addr )
throws UnknownHostException {
+ int n;
NameQueryRequest request = new NameQueryRequest( name );
NameQueryResponse response = new NameQueryResponse();
- request.addr = addr != null ? addr : NbtAddress.getWINSAddress();
- request.isBroadcast = false;
+ request.addr = addr != null ? addr : NbtAddress.getWINSAddress();
+ request.isBroadcast = request.addr == null;
- try {
- send( request, response, RETRY_TIMEOUT );
- } catch( IOException ioe ) {
- if( log.level > 1 )
- ioe.printStackTrace( log );
- throw new UnknownHostException( name.name );
- }
+ if( request.isBroadcast ) {
+ request.addr = baddr;
+ n = RETRY_COUNT;
+ } else {
+ request.isBroadcast = false;
+ n = 1;
+ }
- return response.addrEntry;
- }
+ do {
+ try {
+ send( request, response, RETRY_TIMEOUT );
+ } catch( IOException ioe ) {
+ if( log.level > 1 )
+ ioe.printStackTrace( log );
+ throw new UnknownHostException( name.name );
+ }
+
+ if( response.received && response.resultCode == 0 ) {
+ return response.addrEntry;
+ }
+ } while( --n > 0 && request.isBroadcast );
+
+ throw new UnknownHostException( name.name );
+ }
NbtAddress getByName( Name name, InetAddress addr )
throws UnknownHostException {
int n;
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 );
}
}
}
- 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
* 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;
}
}
if( port == -1 ) {
port = getDefaultPort();
}
- setURL( u, "smb://", u.getHost(), port,
+ setURL( u, "smb", u.getHost(), port,
u.getAuthority(), userinfo,
path, u.getQuery(), null );
}
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() + "]";
+ }
}
// 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
return "0x" + Hexdump.toHexString( errcode, 8 );
}
static int getStatusByCode( int errcode ) {
- if(( errcode & 0xC0000000 ) == 0xC0000000 ) {
+ if(( errcode & 0xC0000000 ) != 0 ) {
return errcode;
} else {
int min = 0;
public class SmbFileInputStream extends InputStream {
- private SmbFile file;
private long fp;
private int readSize, openFlags;
private byte[] tmp = new byte[1];
+ SmbFile file;
+
/**
* Creates an {@link java.io.InputStream} for reading bytes from a file on
* an SMB server addressed by the <code>url</code> parameter. See {@link
public static final int PIPE_TYPE_TRANSACT = 0x02;
+ public static final int PIPE_TYPE_DCE_TRANSACT = 0x02 | 0x04;
+
InputStream pipeIn;
OutputStream pipeOut;
int pipeType;
public final class SmbSession {
- private static final String LOGON_SHARE = Config.getProperty( "jcifs.smb.client.logonShare", "IPC$" );
+ 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 )
public static void logon( UniAddress dc, int port,
NtlmPasswordAuthentication auth ) throws SmbException {
- SmbTransport.getSmbTransport( dc, port ).getSmbSession( auth ).getSmbTree( LOGON_SHARE, null ).treeConnect( null, null );
+ 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;
SmbTransport transport = SmbTransport.NULL_TRANSPORT;
NtlmPasswordAuthentication auth;
- long expiration;
+ long expiration;
SmbSession( UniAddress address, int port,
InetAddress localAddr, int localPort,
void sessionSetup( ServerMessageBlock andx,
ServerMessageBlock andxResponse ) throws SmbException {
- expiration = System.currentTimeMillis() + SmbTransport.SO_TIMEOUT;
+ expiration = System.currentTimeMillis() + SmbTransport.SO_TIMEOUT;
synchronized( transport() ) {
if( sessionSetup ) {
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 =
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;
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;
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;
}
} 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() ) {
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;
SmbComTransactionResponse response ) throws SmbException {
Mid mid = null;
- negotiate();
+ negotiate();
request.flags2 |= flags2;
request.useUnicode = useUnicode;
DfsReferral dr = getDfsReferral( request.auth, request.path );
referrals.add( dr );
throw dr;
+ 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" );
}
}
- state = ST_NEGOTIATED;
+ state = ST_NEGOTIATED;
}
public String toString() {
String ret = "SmbTransport[address=" + address;
import java.io.InputStream;
import java.io.IOException;
+import java.net.UnknownHostException;
+import java.net.MalformedURLException;
-class TransactNamedPipeInputStream extends InputStream {
+class TransactNamedPipeInputStream extends SmbFileInputStream {
private static final int INIT_PIPE_SIZE = 4096;
- private SmbNamedPipe pipe;
private byte[] pipe_buf = new byte[INIT_PIPE_SIZE];
private int beg_idx, nxt_idx, used;
+ private boolean dcePipe;
Object lock;
- TransactNamedPipeInputStream( SmbNamedPipe pipe ) {
- this.pipe = pipe;
+ 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;
lock = new Object();
}
- public void close() throws IOException {
- pipe.close();
- }
public int read() throws IOException {
int result = -1;
used -= result;
beg_idx = ( beg_idx + result ) % pipe_buf.length;
}
+
return result;
}
public int available() throws IOException {
- if( pipe.log.level > 2 )
- pipe.log.println( "Named Pipe available() does not apply to TRANSACT Named Pipes" );
+ if( file.log.level > 2 )
+ file.log.println( "Named Pipe available() does not apply to TRANSACT Named Pipes" );
return 0;
}
int receive( byte[] b, int off, int len ) {
tmp = pipe_buf;
pipe_buf = new byte[new_size];
i = tmp.length - beg_idx;
- if( used > i ) {
+ if( used > i ) { /* 2 chunks */
System.arraycopy( tmp, beg_idx, pipe_buf, 0, i );
System.arraycopy( tmp, 0, pipe_buf, i, used - i );
- nxt_idx = used;
} else {
System.arraycopy( tmp, beg_idx, pipe_buf, 0, used );
}
beg_idx = 0;
+ nxt_idx = used;
tmp = null;
}
used += len;
return len;
}
+ public int dce_read( byte[] b, int off, int len ) throws IOException {
+ return super.read(b, off, len);
+ }
}
private String path;
private SmbNamedPipe pipe;
private byte[] tmp = new byte[1];
+ 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;
path = pipe.unc;
}
new TransCallNamedPipeResponse( pipe ));
} else if(( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_TRANSACT ) ==
SmbNamedPipe.PIPE_TYPE_TRANSACT ) {
- pipe.open(( pipe.pipeType & 0xFF0000 ) | SmbFile.O_EXCL, SmbFile.ATTR_NORMAL, 0 );
- pipe.sendTransaction( new TransTransactNamedPipe( pipe.fid, b, off, len ),
- new TransTransactNamedPipeResponse( pipe ));
+ 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;
+ }
+ pipe.sendTransaction( req, new TransTransactNamedPipeResponse( pipe ));
}
}
}
}
public static String dec_utf8( byte[] src, int si, int slim ) throws IOException {
char[] uni = new char[slim - si];
- int ui = 0, ch;
+ int ui, ch;
for( ui = 0; si < slim && (ch = src[si++] & 0xFF) != 0; ui++ ) {
if( ch < 0x80 ) {
return new String( uni, 0, ui );
}
+ public static String dec_ucs2le( byte[] src, int si, int slim, char[] buf ) throws IOException {
+ int bi;
+
+ 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 );
+ }
}