Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4728A10FA3 for ; Tue, 28 Jan 2014 23:45:36 +0000 (UTC) Received: (qmail 25339 invoked by uid 500); 28 Jan 2014 23:45:35 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 25249 invoked by uid 500); 28 Jan 2014 23:45:34 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 25242 invoked by uid 99); 28 Jan 2014 23:45:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jan 2014 23:45:34 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jan 2014 23:45:33 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2566923888FE; Tue, 28 Jan 2014 23:45:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1562313 - in /directory/shared/trunk: asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/TLV.java ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java Date: Tue, 28 Jan 2014 23:45:13 -0000 To: commits@directory.apache.org From: lucastheisen@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140128234513.2566923888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: lucastheisen Date: Tue Jan 28 23:45:12 2014 New Revision: 1562313 URL: http://svn.apache.org/r1562313 Log: DIRSERVER-1950: Unsafe cast to int in getPwdTimeBeforeExpiry calculation of AuthenticationInterceptor Modified: directory/shared/trunk/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/TLV.java directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java Modified: directory/shared/trunk/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/TLV.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/TLV.java?rev=1562313&r1=1562312&r2=1562313&view=diff ============================================================================== --- directory/shared/trunk/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/TLV.java (original) +++ directory/shared/trunk/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/tlv/TLV.java Tue Jan 28 23:45:12 2014 @@ -222,6 +222,7 @@ public class TLV * * @param length The length to store in a byte array * @return The number of bytes necessary to store the length. + * @see X.690 */ public static int getNbBytes( int length ) { Modified: directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java?rev=1562313&r1=1562312&r2=1562313&view=diff ============================================================================== --- directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java (original) +++ directory/shared/trunk/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ppolicy_impl/PasswordPolicyDecorator.java Tue Jan 28 23:45:12 2014 @@ -27,6 +27,7 @@ import org.apache.directory.api.asn1.Dec import org.apache.directory.api.asn1.EncoderException; import org.apache.directory.api.asn1.ber.Asn1Decoder; import org.apache.directory.api.asn1.ber.tlv.BerValue; +import org.apache.directory.api.asn1.ber.tlv.TLV; import org.apache.directory.api.asn1.ber.tlv.UniversalTag; import org.apache.directory.api.i18n.I18n; import org.apache.directory.api.ldap.codec.api.ControlDecorator; @@ -49,8 +50,8 @@ public class PasswordPolicyDecorator ext // Storage for computed lengths private int ppolicySeqLength = 0; private int warningLength = 0; - private int timeBeforeExpirationTagLength; - private int graceAuthNsRemainingTagLength; + private int timeBeforeExpirationValueLength; + private int graceAuthNsRemainingValueLength; public PasswordPolicyDecorator( LdapApiService codec ) @@ -98,8 +99,8 @@ public class PasswordPolicyDecorator ext valueLength = 0; ppolicySeqLength = 0; warningLength = 0; - timeBeforeExpirationTagLength = 0; - graceAuthNsRemainingTagLength = 0; + timeBeforeExpirationValueLength = 0; + graceAuthNsRemainingValueLength = 0; if ( !hasResponse() ) { @@ -108,18 +109,18 @@ public class PasswordPolicyDecorator ext if ( getResponse().getTimeBeforeExpiration() >= 0 ) { - timeBeforeExpirationTagLength = BerValue.getNbBytes( getResponse().getTimeBeforeExpiration() ); - warningLength = 1 + BerValue.getNbBytes( timeBeforeExpirationTagLength ) + timeBeforeExpirationTagLength; + timeBeforeExpirationValueLength = BerValue.getNbBytes( getResponse().getTimeBeforeExpiration() ); + warningLength = 1 + TLV.getNbBytes( timeBeforeExpirationValueLength ) + timeBeforeExpirationValueLength; } else if ( getResponse().getGraceAuthNRemaining() >= 0 ) { - graceAuthNsRemainingTagLength = BerValue.getNbBytes( getResponse().getGraceAuthNRemaining() ); - warningLength = 1 + BerValue.getNbBytes( graceAuthNsRemainingTagLength ) + graceAuthNsRemainingTagLength; + graceAuthNsRemainingValueLength = BerValue.getNbBytes( getResponse().getGraceAuthNRemaining() ); + warningLength = 1 + TLV.getNbBytes( graceAuthNsRemainingValueLength ) + graceAuthNsRemainingValueLength; } if ( warningLength != 0 ) { - ppolicySeqLength = 1 + BerValue.getNbBytes( warningLength ) + warningLength; + ppolicySeqLength = 1 + TLV.getNbBytes( warningLength ) + warningLength; } if ( getResponse().getPasswordPolicyError() != null ) @@ -129,7 +130,7 @@ public class PasswordPolicyDecorator ext if ( ppolicySeqLength > 0 ) { - valueLength = 1 + BerValue.getNbBytes( ppolicySeqLength ) + ppolicySeqLength; + valueLength = 1 + TLV.getNbBytes( ppolicySeqLength ) + ppolicySeqLength; } return valueLength; @@ -158,24 +159,24 @@ public class PasswordPolicyDecorator ext { // Encode the Sequence tag buffer.put( UniversalTag.SEQUENCE.getValue() ); - buffer.put( BerValue.getBytes( ppolicySeqLength ) ); + buffer.put( TLV.getBytes( ppolicySeqLength ) ); if ( warningLength > 0 ) { // Encode the Warning tag buffer.put( ( byte ) PasswordPolicyTags.PPOLICY_WARNING_TAG.getValue() ); - buffer.put( BerValue.getBytes( warningLength ) ); + buffer.put( TLV.getBytes( warningLength ) ); if ( getResponse().getTimeBeforeExpiration() >= 0 ) { buffer.put( ( byte ) PasswordPolicyTags.TIME_BEFORE_EXPIRATION_TAG.getValue() ); - buffer.put( BerValue.getBytes( timeBeforeExpirationTagLength ) ); + buffer.put( TLV.getBytes( timeBeforeExpirationValueLength ) ); buffer.put( BerValue.getBytes( getResponse().getTimeBeforeExpiration() ) ); } else if ( getResponse().getGraceAuthNRemaining() >= 0 ) { buffer.put( ( byte ) PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG.getValue() ); - buffer.put( BerValue.getBytes( graceAuthNsRemainingTagLength ) ); + buffer.put( TLV.getBytes( graceAuthNsRemainingValueLength ) ); buffer.put( BerValue.getBytes( getResponse().getGraceAuthNRemaining() ) ); } }