directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Karasulu (JIRA)" <directory-...@incubator.apache.org>
Subject [jira] Commented: (DIRSNICKERS-103) Bad encoding of tags number above 127
Date Fri, 18 Feb 2005 04:42:48 GMT
     [ http://issues.apache.org/jira/browse/DIRSNICKERS-103?page=comments#action_59376 ]
     
Alex Karasulu commented on DIRSNICKERS-103:
-------------------------------------------

Ooops looks like these patches make a few test cases fail.  Cannot apply them until all tests
pass.

Here's what failed for me:

org.apache.asn1.ber.BERDecoderTest
org.apache.asn1.ber.MultiByteTagTests

Some others look like they failed as well.  Also could you provide a patch from within the
trunk so the patch gets the fixed class and the test in one shot.  This way I can fold the
change back onto the other branches.

Thanks!



> Bad encoding of tags number above 127
> -------------------------------------
>
>          Key: DIRSNICKERS-103
>          URL: http://issues.apache.org/jira/browse/DIRSNICKERS-103
>      Project: Directory Snickers
>         Type: Bug
>   Components: BER Runtime
>     Versions: 0.2.0
>     Reporter: Emmanuel Lecharny
>     Assignee: Alex Karasulu
>     Priority: Minor
>  Attachments: Tag.diff, TagTest.diff
>
> Tere is a bug in functions :
> org.apache.asn1.ber.Tag.getTagId(byte[])
> and 
> org.apache.asn1.ber.Tag.getTagId(TagOctetCollector)
> when the tag has a number above 127 - which may be very unlikely to happen ! -. In this
case, bytes are decoded in the revert order :
>  ...
>         // calculate tag value w/ long tag format
>         for( int ii = 1 ; ii < octets.length; ii++ )
>         {
>             int shift = ( ii - 1 ) * 7 ;
>             id |= ( octets[ii] & LONG_MASK ) << shift ;
>         }
>  ...
> should be :
>  ...
>         // calculate tag value w/ long tag format
>         for ( int ii = 1; ii < octets.length; ii++ )
>         {
>             id = (id << 7) | (octets[ii] & LONG_MASK);
>         }
>  ...
> in both functions. 
> The test case should also be corrected, as value are create din the revert order in test

> org.apache.asn1.bertestGetTagIdByteArray() :
> ...
>             octets[1] = (byte)(ii & Tag.LONG_MASK);
>             octets[2] = (byte)((ii >> 7) & Tag.LONG_MASK);
> ...
> should be :
> ...
>             octets[1] = (byte)((ii >> 7) & Tag.LONG_MASK);
>             octets[2] = (byte)(ii & Tag.LONG_MASK);
> ...
> and
> ...
>             octets[1] = (byte)(ii & Tag.LONG_MASK);
>             octets[2] = (byte)((ii >> 7) & Tag.LONG_MASK);
>             octets[3] = (byte)((ii >> 14) & Tag.LONG_MASK);
> ...
> should be :
> ...
>             octets[1] = (byte)((ii >> 14) & Tag.LONG_MASK);
>             octets[2] = (byte)((ii >> 7) & Tag.LONG_MASK);
>             octets[3] = (byte)(ii & Tag.LONG_MASK);
> ...
> Function org.apache.asn1.ber.Tag.getTagId(int) seems to works correctly - although not
tested.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


Mime
View raw message