directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maxim Solodovnik <solomax...@gmail.com>
Subject Re: The length of controls must not be null
Date Mon, 03 Apr 2017 15:07:40 GMT
Sure

Thanks a lot for the investigation!

On Mon, Apr 3, 2017 at 9:58 PM, Emmanuel Lécharny <elecharny@gmail.com> wrote:
>
>
> Le 03/04/2017 à 14:22, Maxim Solodovnik a écrit :
>> Yes,
>> Search for the user from OM (via directory API) fails with
>> "DecoderException: The length of controls must not be null"
>> (The full stack trace is in the first message of this thread)
>
>
>
> Sorry that it took me so understand what was going on. The stack trace
> is clear a control should not be null. We do have a null control in the
> SearcResultDone :
>
> 0000   30 0e 02 01 02 65 07 0a 01 00 04 00 04 00 a0 00
>
> which is :
>
> 30 0e             LdapMessage
>   02 01 02        Message ID : 02
>   65 07           ProtocolOp : SearchResultDone
>     0a 01 00      LDAPResult.resultCode  : LDAP_SUCCESS
>     04 00         LDAPResult.matchedDN : ""
>     04 00         LDAPResult.errorMessage : ""
>     a0 00         Controls : empty
>
>
> Going back to RFC 4511 :
>
> LDAPMessage ::= SEQUENCE {
>              messageID       MessageID,
>              protocolOp      CHOICE {
>                   ...
>                   searchResDone         SearchResultDone,
>                   ...,
>                   intermediateResponse  IntermediateResponse },
>              controls       [0] Controls OPTIONAL }
>
> We may have no controls, as it's optional. In this case, the 0xA0 ...
> part at the end will simply not exist. Let's see what is Controls
> structure :
>
> Controls ::= SEQUENCE OF control Control
>
>
> Here, if the SEQUENCE is empty, the encoded bytes for the length wll be
> 0x00, so we will have 0xA0 0x00.
>
> The Controls code in the API is :
>
>     public void action( LdapMessageContainer<MessageDecorator<? extends
> Message>> container ) throws DecoderException
>     {
>         TLV tlv = container.getCurrentTLV();
>         int expectedLength = tlv.getLength();
>
>         // The Length should be null
>         if ( expectedLength == 0 )
>         {
>             LOG.error( "The length of controls must not be null" );
>
>             // This will generate a PROTOCOL_ERROR
>             throw new DecoderException( "The length of controls must not
> be null" );
>         }
>
>         if ( IS_DEBUG )
>         {
>             LOG.debug( "A new list of controls has been initialized" );
>         }
>     }
>
>
> As you can see, there are two errors :
> - the comment is wrong and should read : "The Length should *not* be null
> - the length could actually be null
>
> Bottom line, this is a bug that need to be fixed, and I'll do that ASAP.
>
> May I ask you to filla  JIRA with your first mail ad the stack trace for
> clarity ?
>
> Thanks !
>
> --
> Emmanuel Lecharny
>
> Symas.com
> directory.apache.org
>



-- 
WBR
Maxim aka solomax

Mime
View raw message