mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

sin
29.58.2009 741434f68eb3494bb222f4386d56ce0acb32a1c6
Additional fix for issue 4181: NPE in DSML search requests.
2 files modified
28 ■■■■■ changed files
opends/src/dsml/org/opends/dsml/protocol/DSMLSearchOperation.java 26 ●●●●● patch | view | raw | blame | history
opends/src/messages/messages/protocol.properties 2 ●●●●● patch | view | raw | blame | history
opends/src/dsml/org/opends/dsml/protocol/DSMLSearchOperation.java
@@ -43,6 +43,7 @@
import org.opends.server.protocols.ldap.LDAPConstants;
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.protocols.ldap.LDAPMessage;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.protocols.ldap.SearchRequestProtocolOp;
import org.opends.server.protocols.ldap.SearchResultEntryProtocolOp;
import org.opends.server.protocols.ldap.SearchResultDoneProtocolOp;
@@ -52,6 +53,7 @@
import org.opends.server.types.LDAPException;
import org.opends.server.types.RawFilter;
import org.opends.server.types.SearchScope;
import static org.opends.messages.ProtocolMessages.*;
@@ -271,6 +273,7 @@
   *         information.
   */
  private static LDAPFilter createSubstringFilter(SubstringFilter sf)
        throws LDAPException
  {
    List<String> anys = sf.getAny();
    ArrayList<ByteString> subAnyElements = new ArrayList<ByteString>(anys
@@ -280,6 +283,12 @@
    {
      subAnyElements.add(ByteString.valueOf(s));
    }
    if(sf.getInitial() == null && subAnyElements.isEmpty()
            && sf.getFinal()==null)
    {
      Message message = ERR_LDAP_FILTER_DECODE_NULL.get();
      throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message);
    }
    return LDAPFilter.createSubstringFilter(sf.getName(), sf.getInitial()==null?
      null:ByteString.valueOf(sf.getInitial()), subAnyElements,
      sf.getFinal()==null?null:ByteString.valueOf(sf.getFinal()));
@@ -514,7 +523,22 @@
        int resultCode = 0;
        Message errorMessage = null;
        LDAPMessage responseMessage = connection.getLDAPReader().readMessage();
        if(responseMessage == null)
        {
          //The server disconnected silently. At this point we don't know if it
          // is a protocol error or anything else. Since we didn't hear from
          // the server , we have a reason to believe that the server doesn't
          // want to handle this request. Let us return unavailable error
          // code to the client to cover possible cases.
          Message message = ERR_UNEXPECTED_CONNECTION_CLOSURE.get();
          LDAPResult result = objFactory.createLDAPResult();
          ResultCode code = objFactory.createResultCode();
          code.setCode(LDAPResultCode.UNAVAILABLE);
          result.setResultCode(code);
          result.setErrorMessage(message.toString());
          searchResponse.setSearchResultDone(result);
          return searchResponse;
        }
        opType = responseMessage.getProtocolOpType();
        switch (opType)
        {
opends/src/messages/messages/protocol.properties
@@ -1419,4 +1419,6 @@
MILD_ERR_ECLN_CANNOT_DECODE_VALUE_1510=Cannot decode the provided entry \
 changelog notification control because an error occurred while attempting to \
 decode the control value:  %s
SEVERE_ERR_UNEXPECTED_CONNECTION_CLOSURE_1511=The connection to the Directory \
Server was closed while waiting for a response