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

coulbeck
11.30.2006 62b5bb664127c04d051d90d001a07e8fd6f9adb9
Fix for issue 629.

I rearranged the operands in the if statement to avoid possibility of integer overflow, and I fixed the log message to calculate the remaining bytes correctly. The second chunk of the diff is the important one, the first chunk is for consistency only. I didn't spot any other code having the same issue.

With this fix, there are no errors in the server log after running the OULU test suites and the server is still accepting requests.
1 files modified
6 ■■■■ changed files
opends/src/server/org/opends/server/protocols/asn1/ASN1Element.java 6 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/protocols/asn1/ASN1Element.java
@@ -969,7 +969,7 @@
          throw new ASN1Exception(msgID, message);
        }
        if ((startPos + numLengthBytes) > encodedElements.length)
        if (numLengthBytes > encodedElements.length - startPos)
        {
          int    msgID   = MSGID_ASN1_ELEMENT_SET_TRUNCATED_LENGTH;
          String message = getMessage(msgID, numLengthBytes);
@@ -985,11 +985,11 @@
      // Make sure that there are at least enough bytes to hold the value.
      if ((startPos + length) > encodedElements.length)
      if (length > encodedElements.length - startPos)
      {
        int    msgID   = MSGID_ASN1_ELEMENT_SET_TRUNCATED_VALUE;
        String message = getMessage(msgID, length,
                                    (startPos+length-encodedElements.length));
                                    (encodedElements.length-startPos));
        throw new ASN1Exception(msgID, message);
      }