[jcifs] Bug: Error in SmbTree.java??

Johannes Bredner johannes.bredner at googlemail.com
Thu Feb 19 13:29:25 GMT 2009


Hi all there,

i think i`ve found a bug in SmbTree.java. Here the Problem:

In the constructor of Trans2FindFirst2.java

Trans2FindFirst2(String filename, String wildcard, int searchAttributes){
........
command = SMB_COM_TRANSACTION2;
subCommand = TRANS2_FIND_FIRST2;
.....
}

This subcommand results in an exception in SmbTree.java



------------------------------------------------------------------------------------------------------------------------
void send( ServerMessageBlock request,
                           ServerMessageBlock response ) throws
SmbException {
       if( response != null ) {
           response.received = false;
       }
       treeConnect( request, response );
       if( request == null || (response != null && response.received )) {
           return;
       }
       if( service.equals( "A:" ) == false ) {
           switch( request.command ) {
               case ServerMessageBlock.SMB_COM_OPEN_ANDX:
               case ServerMessageBlock.SMB_COM_NT_CREATE_ANDX:
               case ServerMessageBlock.SMB_COM_READ_ANDX:
               case ServerMessageBlock.SMB_COM_WRITE_ANDX:
               case ServerMessageBlock.SMB_COM_CLOSE:
               case ServerMessageBlock.SMB_COM_TREE_DISCONNECT:
                   break;
               case ServerMessageBlock.SMB_COM_TRANSACTION:
               case ServerMessageBlock.SMB_COM_TRANSACTION2:
                   switch( ((SmbComTransaction)request).subCommand & 0xFF
) {
                       case SmbComTransaction.NET_SHARE_ENUM:
                       case SmbComTransaction.NET_SERVER_ENUM2:
                       case SmbComTransaction.NET_SERVER_ENUM3:
                       case SmbComTransaction.TRANS_PEEK_NAMED_PIPE:
                       case SmbComTransaction.TRANS_WAIT_NAMED_PIPE:
                       case SmbComTransaction.TRANS_CALL_NAMED_PIPE:
                       case SmbComTransaction.TRANS_TRANSACT_NAMED_PIPE:
                       case SmbComTransaction.TRANS2_GET_DFS_REFERRAL:
                           break;
                       default:
                             throw new SmbException( "Invalid operation
for " + service + " service" );
                   }
                   break;
               default:
                   throw new SmbException( "Invalid operation for " +
service + " service" + request );
           }
       }
       request.tid = tid;
------------------------------------------------------------------------------------------------------------------------

throws the Exception "Invalid operation for service". Here my idea:


------------------------------------------------------------------------------------------------------------------------
void send( ServerMessageBlock request,
                           ServerMessageBlock response ) throws
SmbException {
       if( response != null ) {
           response.received = false;
       }
       treeConnect( request, response );
       if( request == null || (response != null && response.received )) {
           return;
       }
       if( service.equals( "A:" ) == false ) {
           switch( request.command ) {
               case ServerMessageBlock.SMB_COM_OPEN_ANDX:
               case ServerMessageBlock.SMB_COM_NT_CREATE_ANDX:
               case ServerMessageBlock.SMB_COM_READ_ANDX:
               case ServerMessageBlock.SMB_COM_WRITE_ANDX:
               case ServerMessageBlock.SMB_COM_CLOSE:
               case ServerMessageBlock.SMB_COM_TREE_DISCONNECT:
                   break;
               case ServerMessageBlock.SMB_COM_TRANSACTION:
               case ServerMessageBlock.SMB_COM_TRANSACTION2:
                   switch( ((SmbComTransaction)request).subCommand & 0xFF
) {
                       case SmbComTransaction.NET_SHARE_ENUM:
                       case SmbComTransaction.NET_SERVER_ENUM2:
                       case SmbComTransaction.NET_SERVER_ENUM3:
                       case SmbComTransaction.TRANS_PEEK_NAMED_PIPE:
                       case SmbComTransaction.TRANS_WAIT_NAMED_PIPE:
                       case SmbComTransaction.TRANS_CALL_NAMED_PIPE:
                       case SmbComTransaction.TRANS_TRANSACT_NAMED_PIPE:
                       case SmbComTransaction.TRANS2_GET_DFS_REFERRAL:
                       *case SmbComTransaction.TRANS2_FIND_FIRST2:
*                           break;
                       default:
                             throw new SmbException( "Invalid operation
for " + service + " service" );
                   }
                   break;
               default:
                   throw new SmbException( "Invalid operation for " +
service + " service" + request );
           }
       }
       request.tid = tid;

------------------------------------------------------------------------------------------------------------------------

If i add the subcommand line for TRANS2_FIND_FIRST2 everything works fine,
but i don`t really know if this is the right way to fix the problem. Just
seems, that this command is missing in the list.

Do you agree with my fix? Is this the right way to report bugs?

Please answer to this email, because i`m not on the list at the moment.

Best regards,

Johannes
-------------- next part --------------
HTML attachment scrubbed and removed


More information about the jcifs mailing list