directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r596828 - in /directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap: codec/ codec/bind/ codec/extended/ codec/extended/operations/ codec/util/ entry/ filter/ ldif/ message/ message/extended/ schema/ util/
Date Tue, 20 Nov 2007 21:08:58 GMT
Author: felixk
Date: Tue Nov 20 13:08:56 2007
New Revision: 596828

URL: http://svn.apache.org/viewvc?rev=596828&view=rev
Log:
May expose internal representation by incorporating reference to mutable object

This code stores a reference to an externally mutable object into the internal representation
of the object.  If instances are accessed by untrusted code, and unchecked changes to the
mutable object would compromise security or other important properties, you will need to do
something different. Storing a copy of the object is better approach in many situations.

Modified:
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SimpleAuthentication.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequest.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedure.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/BindRequestImpl.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/BindResponseImpl.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequestImpl.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ExtendedRequestImpl.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ExtendedResponseImpl.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulDisconnect.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulShutdownRequest.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/RegexNormalizer.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/ArrayEnumeration.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/JoinIterator.java

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java
Tue Nov 20 13:08:56 2007
@@ -119,7 +119,12 @@
      */
     public void setEncodedValue( byte[] encodedValue )
     {
-        this.encodedValue = encodedValue;
+        if ( encodedValue != null ) {
+            this.encodedValue = new byte[ encodedValue.length ];
+            System.arraycopy( encodedValue, 0, this.encodedValue, 0, encodedValue.length
);
+        } else {
+            this.encodedValue = null;
+        }
     }
 
 
@@ -135,7 +140,9 @@
             return StringTools.EMPTY_BYTES;
         }
 
-        return encodedValue;
+        final byte[] copy = new byte[ encodedValue.length ];
+        System.arraycopy( encodedValue, 0, copy, 0, encodedValue.length );
+        return copy;
     }
 
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java
Tue Nov 20 13:08:56 2007
@@ -85,7 +85,14 @@
      */
     public byte[] getServerSaslCreds()
     {
-        return serverSaslCreds;
+        if ( serverSaslCreds == null )
+        {
+            return null;
+        }
+
+        final byte[] copy = new byte[ serverSaslCreds.length ];
+        System.arraycopy( serverSaslCreds, 0, copy, 0, serverSaslCreds.length );
+        return copy;
     }
 
 
@@ -96,7 +103,12 @@
      */
     public void setServerSaslCreds( byte[] serverSaslCreds )
     {
-        this.serverSaslCreds = serverSaslCreds;
+        if ( serverSaslCreds != null ) {
+            this.serverSaslCreds = new byte[ serverSaslCreds.length ];
+            System.arraycopy( serverSaslCreds, 0, this.serverSaslCreds, 0, serverSaslCreds.length
);
+        } else {
+            this.serverSaslCreds = null;
+        }
     }
 
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java
Tue Nov 20 13:08:56 2007
@@ -84,7 +84,14 @@
      */
     public byte[] getCredentials()
     {
-        return credentials;
+        if ( credentials == null )
+        {
+            return null;
+        }
+
+        final byte[] copy = new byte[ credentials.length ];
+        System.arraycopy( credentials, 0, copy, 0, credentials.length );
+        return copy;
     }
 
 
@@ -95,7 +102,12 @@
      */
     public void setCredentials( byte[] credentials )
     {
-        this.credentials = credentials;
+        if ( credentials != null ) {
+            this.credentials = new byte[ credentials.length ];
+            System.arraycopy( credentials, 0, this.credentials, 0, credentials.length );
+        } else {
+            this.credentials = null;
+        }
     }
 
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SimpleAuthentication.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SimpleAuthentication.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SimpleAuthentication.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SimpleAuthentication.java
Tue Nov 20 13:08:56 2007
@@ -69,7 +69,14 @@
      */
     public byte[] getSimple()
     {
-        return simple;
+        if ( simple == null )
+        {
+            return null;
+        }
+
+        final byte[] copy = new byte[ simple.length ];
+        System.arraycopy( simple, 0, copy, 0, simple.length );
+        return copy;
     }
 
 
@@ -80,7 +87,12 @@
      */
     public void setSimple( byte[] simple )
     {
-        this.simple = simple;
+        if ( simple != null ) {
+            this.simple = new byte[ simple.length ];
+            System.arraycopy( simple, 0, this.simple, 0, simple.length );
+        } else {
+            this.simple = null;
+        }
     }
 
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequest.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequest.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequest.java
Tue Nov 20 13:08:56 2007
@@ -112,7 +112,14 @@
      */
     public byte[] getRequestValue()
     {
-        return requestValue;
+        if ( requestValue == null )
+        {
+            return null;
+        }
+
+        final byte[] copy = new byte[ requestValue.length ];
+        System.arraycopy( requestValue, 0, copy, 0, requestValue.length );
+        return copy;
     }
 
 
@@ -123,7 +130,12 @@
      */
     public void setRequestValue( byte[] requestValue )
     {
-        this.requestValue = requestValue;
+        if ( requestValue != null ) {
+            this.requestValue = new byte[ requestValue.length ];
+            System.arraycopy( requestValue, 0, this.requestValue, 0, requestValue.length
);
+        } else {
+            this.requestValue = null;
+        }
     }
 
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedure.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedure.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedure.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedure.java
Tue Nov 20 13:08:56 2007
@@ -80,13 +80,25 @@
 
     public byte[] getProcedure()
     {
-        return procedure;
+        if ( procedure == null )
+        {
+            return null;
+        }
+
+        final byte[] copy = new byte[ procedure.length ];
+        System.arraycopy( procedure, 0, copy, 0, procedure.length );
+        return copy;
     }
 
 
     public void setProcedure( byte[] procedure )
     {
-        this.procedure = procedure;
+        if ( procedure != null ) {
+            this.procedure = new byte[ procedure.length ];
+            System.arraycopy( procedure, 0, this.procedure, 0, procedure.length );
+        } else {
+            this.procedure = null;
+        }
     }
 
 
@@ -126,25 +138,49 @@
 
         public byte[] getType()
         {
-            return type;
+            if ( type == null )
+            {
+                return null;
+            }
+
+            final byte[] copy = new byte[ type.length ];
+            System.arraycopy( type, 0, copy, 0, type.length );
+            return copy;
         }
 
 
         public void setType( byte[] type )
         {
-            this.type = type;
+            if ( type != null ) {
+                this.type = new byte[ type.length ];
+                System.arraycopy( type, 0, this.type, 0, type.length );
+            } else {
+                this.type = null;
+            }
         }
 
 
         public byte[] getValue()
         {
-            return value;
+            if ( value == null )
+            {
+                return null;
+            }
+
+            final byte[] copy = new byte[ value.length ];
+            System.arraycopy( value, 0, copy, 0, value.length );
+            return copy;
         }
 
 
         public void setValue( byte[] value )
         {
-            this.value = value;
+            if ( value != null ) {
+                this.value = new byte[ value.length ];
+                System.arraycopy( value, 0, this.value, 0, value.length );
+            } else {
+                this.value = null;
+            }
         }
     }
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/util/LdapURL.java
Tue Nov 20 13:08:56 2007
@@ -329,7 +329,13 @@
         }
 
         string = StringTools.utf8ToString( bytes );
-        this.bytes = bytes;
+
+        if ( bytes != null ) {
+            this.bytes = new byte[ bytes.length ];
+            System.arraycopy( bytes, 0, this.bytes, 0, bytes.length );
+        } else {
+            this.bytes = null;
+        }
 
         parse( string.toCharArray() );
     }

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java
Tue Nov 20 13:08:56 2007
@@ -58,7 +58,12 @@
      */
     public BinaryValue( byte[] wrapped )
     {
-        this.wrapped = wrapped;
+        if ( wrapped != null ) {
+            this.wrapped = new byte[ wrapped.length ];
+            System.arraycopy( wrapped, 0, this.wrapped, 0, wrapped.length );
+        } else {
+            this.wrapped = null;
+        }
     }
 
 
@@ -87,7 +92,14 @@
      */
     public byte[] get()
     {
-        return wrapped;
+        if ( wrapped == null )
+        {
+            return null;
+        }
+
+        final byte[] copy = new byte[ wrapped.length ];
+        System.arraycopy( wrapped, 0, copy, 0, wrapped.length );
+        return copy;
     }
 
 
@@ -96,10 +108,14 @@
      *
      * @param src the source byte array to use as the wrapped value
      */
-    public void set( byte[] src )
+    public void set( byte[] wrapped )
     {
-        wrapped = new byte[ src.length];
-        System.arraycopy( src, 0, wrapped, 0, src.length );
+        if ( wrapped != null ) {
+            this.wrapped = new byte[ wrapped.length ];
+            System.arraycopy( wrapped, 0, this.wrapped, 0, wrapped.length );
+        } else {
+            this.wrapped = null;
+        }
     }
 
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ExtensibleNode.java
Tue Nov 20 13:08:56 2007
@@ -77,7 +77,13 @@
     {
         super( attribute );
 
-        this.value = value;
+        if ( value != null ) {
+            this.value = new byte[ value.length ];
+            System.arraycopy( value, 0, this.value, 0, value.length );
+        } else {
+            this.value = null;
+        }
+
         this.matchingRuleId = matchingRuleId;
         this.dnAttributes = dnAttributes;
     }
@@ -132,7 +138,14 @@
      */
     public final byte[] getValue()
     {
-        return value;
+        if ( value == null )
+        {
+            return null;
+        }
+
+        final byte[] copy = new byte[ value.length ];
+        System.arraycopy( value, 0, copy, 0, value.length );
+        return copy;
     }
 
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
Tue Nov 20 13:08:56 2007
@@ -100,7 +100,14 @@
      */
     public byte[] getEncodedValue()
     {
-        return value;
+        if ( value == null )
+        {
+            return null;
+        }
+
+        final byte[] copy = new byte[ value.length ];
+        System.arraycopy( value, 0, copy, 0, value.length );
+        return copy;
     }
 
     /**
@@ -111,7 +118,12 @@
      */
     public void setValue( byte[] value )
     {
-        this.value = value;
+        if ( value != null ) {
+            this.value = new byte[ value.length ];
+            System.arraycopy( value, 0, this.value, 0, value.length );
+        } else {
+            this.value = null;
+        }
     }
 
     public String toString()

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/BindRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/BindRequestImpl.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/BindRequestImpl.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/BindRequestImpl.java
Tue Nov 20 13:08:56 2007
@@ -140,7 +140,12 @@
      */
     public void setCredentials( byte[] credentials )
     {
-        this.credentials = credentials;
+        if ( credentials != null ) {
+            this.credentials = new byte[ credentials.length ];
+            System.arraycopy( credentials, 0, this.credentials, 0, credentials.length );
+        } else {
+            this.credentials = null;
+        }
         
         if ( credentials != null )
         {

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/BindResponseImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/BindResponseImpl.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/BindResponseImpl.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/BindResponseImpl.java
Tue Nov 20 13:08:56 2007
@@ -68,7 +68,14 @@
      */
     public byte[] getServerSaslCreds()
     {
-        return serverSaslCreds;
+        if ( serverSaslCreds == null )
+        {
+            return null;
+        }
+
+        final byte[] copy = new byte[ serverSaslCreds.length ];
+        System.arraycopy( serverSaslCreds, 0, copy, 0, serverSaslCreds.length );
+        return copy;
     }
 
 
@@ -82,7 +89,12 @@
      */
     public void setServerSaslCreds( byte[] serverSaslCreds )
     {
-        this.serverSaslCreds = serverSaslCreds;
+        if ( serverSaslCreds != null ) {
+            this.serverSaslCreds = new byte[ serverSaslCreds.length ];
+            System.arraycopy( serverSaslCreds, 0, this.serverSaslCreds, 0, serverSaslCreds.length
);
+        } else {
+            this.serverSaslCreds = null;
+        }
     }
 
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequestImpl.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequestImpl.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/CompareRequestImpl.java
Tue Nov 20 13:08:56 2007
@@ -125,7 +125,12 @@
      */
     public void setAssertionValue( byte[] attrVal )
     {
-        this.attrVal = attrVal;
+        if ( attrVal != null ) {
+            this.attrVal = new byte[ attrVal.length ];
+            System.arraycopy( attrVal, 0, this.attrVal, 0, attrVal.length );
+        } else {
+            this.attrVal = null;
+        }
     }
 
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ExtendedRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ExtendedRequestImpl.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ExtendedRequestImpl.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ExtendedRequestImpl.java
Tue Nov 20 13:08:56 2007
@@ -101,7 +101,14 @@
      */
     public byte[] getPayload()
     {
-        return payload;
+        if ( payload == null )
+        {
+            return null;
+        }
+
+        final byte[] copy = new byte[ payload.length ];
+        System.arraycopy( payload, 0, copy, 0, payload.length );
+        return copy;
     }
 
 
@@ -113,7 +120,12 @@
      */
     public void setPayload( byte[] payload )
     {
-        this.payload = payload;
+        if ( payload != null ) {
+            this.payload = new byte[ payload.length ];
+            System.arraycopy( payload, 0, this.payload, 0, payload.length );
+        } else {
+            this.payload = null;
+        }
     }
 
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ExtendedResponseImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ExtendedResponseImpl.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ExtendedResponseImpl.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/ExtendedResponseImpl.java
Tue Nov 20 13:08:56 2007
@@ -73,19 +73,31 @@
      */
     public byte[] getResponse()
     {
-        return value;
+        if ( value == null )
+        {
+            return null;
+        }
+
+        final byte[] copy = new byte[ value.length ];
+        System.arraycopy( value, 0, copy, 0, value.length );
+        return copy;
     }
 
 
     /**
-     * Sets the reponse OID specific encoded response values.
+     * Sets the response OID specific encoded response values.
      * 
      * @param value
      *            the response specific encoded response values.
      */
     public void setResponse( byte[] value )
     {
-        this.value = value;
+        if ( value != null ) {
+            this.value = new byte[ value.length ];
+            System.arraycopy( value, 0, this.value, 0, value.length );
+        } else {
+            this.value = null;
+        }
     }
     
     

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulDisconnect.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulDisconnect.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulDisconnect.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulDisconnect.java
Tue Nov 20 13:08:56 2007
@@ -71,7 +71,12 @@
     public GracefulDisconnect(byte[] value) throws DecoderException
     {
         super( 0, EXTENSION_OID );
-        this.value = value;
+        if ( value != null ) {
+            this.value = new byte[ value.length ];
+            System.arraycopy( value, 0, this.value, 0, value.length );
+        } else {
+            this.value = null;
+        }
         decodeValue();
     }
 
@@ -172,7 +177,10 @@
         {
             encodeResponse();
         }
-        return value;
+
+        final byte[] copy = new byte[ value.length ];
+        System.arraycopy( value, 0, copy, 0, value.length );
+        return copy;
     }
 
 
@@ -208,7 +216,12 @@
             replicatedContexts.addLdapUrl( url.toString() );
         }
 
-        this.value = value;
+        if ( value != null ) {
+            this.value = new byte[ value.length ];
+            System.arraycopy( value, 0, this.value, 0, value.length );
+        } else {
+            this.value = null;
+        }
     }
 
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulShutdownRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulShutdownRequest.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulShutdownRequest.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulShutdownRequest.java
Tue Nov 20 13:08:56 2007
@@ -95,7 +95,12 @@
         try
         {
             GracefulShutdown gs = ( GracefulShutdown ) decoder.decode( payload );
-            this.payload = payload;
+            if ( payload != null ) {
+                this.payload = new byte[ payload.length ];
+                System.arraycopy( payload, 0, this.payload, 0, payload.length );
+            } else {
+                this.payload = null;
+            }
             this.timeOffline = gs.getTimeOffline();
             this.delay = gs.getDelay();
         }
@@ -135,7 +140,14 @@
             }
         }
 
-        return payload;
+        if ( payload == null )
+        {
+            return null;
+        }
+
+        final byte[] copy = new byte[ payload.length ];
+        System.arraycopy( payload, 0, copy, 0, payload.length );
+        return copy;
     }
 
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/RegexNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/RegexNormalizer.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/RegexNormalizer.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/schema/RegexNormalizer.java
Tue Nov 20 13:08:56 2007
@@ -49,7 +49,12 @@
      */
     public RegexNormalizer(Pattern[] regexes)
     {
-        this.regexes = regexes;
+        if ( regexes != null ) {
+            this.regexes = new Pattern[ regexes.length ];
+            System.arraycopy( regexes, 0, this.regexes, 0, regexes.length );
+        } else {
+            this.regexes = null;
+        }
         matchers = new Matcher[regexes.length];
 
         for ( int i = 0; i < regexes.length; i++ )

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/ArrayEnumeration.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/ArrayEnumeration.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/ArrayEnumeration.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/ArrayEnumeration.java
Tue Nov 20 13:08:56 2007
@@ -47,7 +47,12 @@
      */
     public ArrayEnumeration(Object[] array)
     {
-        this.array = array;
+        if ( array != null ) {
+            this.array = new Object[ array.length ];
+            System.arraycopy( array, 0, this.array, 0, array.length );
+        } else {
+            this.array = null;
+        }
     }
 
 

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/JoinIterator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/JoinIterator.java?rev=596828&r1=596827&r2=596828&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/JoinIterator.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/util/JoinIterator.java
Tue Nov 20 13:08:56 2007
@@ -55,7 +55,12 @@
                 + "null, empty or composed of less than two Iterators" );
         }
 
-        this.iterators = iterators;
+        if ( iterators != null ) {
+            this.iterators = new Iterator[ iterators.length ];
+            System.arraycopy( iterators, 0, this.iterators, 0, iterators.length );
+        } else {
+            this.iterators = null;
+        }
         this.index = 0;
     }
 



Mime
View raw message