You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Emmanuel Lecharny (JIRA)" <di...@incubator.apache.org> on 2005/02/10 23:57:12 UTC
[jira] Created: (DIR-105) Bad encoding of tags number above 127
Bad encoding of tags number above 127
-------------------------------------
Key: DIR-105
URL: http://issues.apache.org/jira/browse/DIR-105
Project: Directory
Type: Bug
Reporter: Emmanuel Lecharny
Assigned to: Alex Karasulu
Priority: Minor
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
[jira] Updated: (DIRSNICKERS-103) Bad encoding of tags number above 127
Posted by "Emmanuel Lecharny (JIRA)" <di...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/DIRSNICKERS-103?page=history ]
Emmanuel Lecharny updated DIRSNICKERS-103:
------------------------------------------
Attachment: asn1-ber.diff
Here are corrections for the issue. All the asn1-ber test are successful, with wome kind of weird messages, which seems to be "expected" errors ... :
[elecharny@wkslx01 ber]$ maven test
__ __
| \/ |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \ ~ intelligent projects ~
|_| |_\__,_|\_/\___|_||_| v. 1.0.2
Attempting to download asn1-codec-0.3-SNAPSHOT.jar.
Attempting to download ldap-common-0.9-SNAPSHOT.jar.
Attempting to download ldap-snacc-provider-0.9-SNAPSHOT.jar.
build:start:
java:prepare-filesystem:
java:compile:
[echo] Compiling to /home/elecharny/apache-ds-good/asn1/trunk/ber/target/classes
[echo]
==========================================================
NOTE: Targetting JVM 1.4, classes
will not run on earlier JVMs
==========================================================
java:jar-resources:
test:prepare-filesystem:
test:test-resources:
test:compile:
test:test:
[junit] Running org.apache.asn1.ber.BERDecoderCallbackAdapterTest
[junit] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.027 sec
[junit] Running org.apache.asn1.ber.SimplePrimitiveTLVTests
[junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0.11 sec
[junit] Running org.apache.asn1.ber.ConstructedTLVTests
[junit] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.049 sec
[junit] Running org.apache.asn1.ber.MultiByteTagTests
[junit] Tests run: 9, Failures: 0, Errors: 0, Time elapsed: 0.051 sec
[junit] Running org.apache.asn1.ber.SingleByteLengthTests
[junit] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.123 sec
[junit] Running org.apache.asn1.ber.SingleByteTagTests
[junit] Tests run: 37, Failures: 0, Errors: 0, Time elapsed: 0.058 sec
[junit] Running org.apache.asn1.ber.EncodeDecodeTests
[junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.142 sec
[junit] Running org.apache.asn1.ber.MultiByteLengthTests
[junit] Tests run: 5, Failures: 0, Errors: 0, Time elapsed: 0.112 sec
[junit] Running org.apache.asn1.ber.BEREncoderTest
[junit] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.033 sec
[junit] Running org.apache.asn1.ber.BERDecoderStateTest
[junit] Tests run: 7, Failures: 0, Errors: 0, Time elapsed: 0.028 sec
[junit] Running org.apache.asn1.ber.LengthTest
[junit] Tests run: 6, Failures: 0, Errors: 0, Time elapsed: 0.006 sec
[junit] Running org.apache.asn1.ber.LdapMessageTests
[junit] Tests run: 9, Failures: 0, Errors: 0, Time elapsed: 0.207 sec
[junit] Running org.apache.asn1.ber.TypeClassTest
[junit] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.019 sec
[junit] Running org.apache.asn1.ber.TupleTreeDecoderTest
[junit] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.122 sec
[junit] Running org.apache.asn1.ber.TupleTest
[junit] Tests run: 24, Failures: 0, Errors: 0, Time elapsed: 0.027 sec
[junit] Running org.apache.asn1.ber.digester.BERDigesterTest
Error while triggering rule org.apache.asn1.ber.digester.BERDigesterTest$ErrorRule@c67a88 with digester org.apache.asn1.ber.digester.BERDigester@96ad7c: Rule.tag() threw error
java.lang.Error
at org.apache.asn1.ber.digester.BERDigesterTest$ErrorRule.tag(BERDigesterTest.java:939)
at org.apache.asn1.ber.digester.BERDigester.fireTagEvent(BERDigester.java:1033)
at org.apache.asn1.ber.digester.BERDigester$DigesterCallback.tagDecoded(BERDigester.java:164)
at org.apache.asn1.ber.BERDecoder.fireTagDecoded(BERDecoder.java:357)
at org.apache.asn1.ber.BERDecoder.decodeOccurred(BERDecoder.java:274)
at org.apache.asn1.codec.stateful.AbstractStatefulDecoder.decodeOccurred(AbstractStatefulDecoder.java:130)
at org.apache.asn1.ber.TagDecoder.decode(TagDecoder.java:57)
at org.apache.asn1.ber.BERDecoder.decode(BERDecoder.java:153)
at org.apache.asn1.ber.digester.BERDigester.decode(BERDigester.java:145)
at org.apache.asn1.ber.digester.BERDigesterTest.testErrorOnTag(BERDigesterTest.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
(lines and lines and lines)
...
at java.lang.reflect.Method.invoke(Method.java:324)
at com.werken.forehead.Forehead.run(Forehead.java:551)
at com.werken.forehead.Forehead.main(Forehead.java:581)
[junit] Tests run: 29, Failures: 0, Errors: 0, Time elapsed: 358.463 sec
[junit] Running org.apache.asn1.ber.digester.TagTreeTest
[junit] Tests run: 13, Failures: 0, Errors: 0, Time elapsed: 0.026 sec
[junit] Running org.apache.asn1.ber.digester.rules.ByteAccumulatorTest
[junit] Tests run: 8, Failures: 0, Errors: 0, Time elapsed: 0.011 sec
[junit] Running org.apache.asn1.ber.digester.rules.PrimitiveOctetStringRuleTest
[junit] Tests run: 5, Failures: 0, Errors: 0, Time elapsed: 0.128 sec
[junit] Running org.apache.asn1.ber.digester.rules.PrimitiveIntDecodeRuleTest
[junit] Tests run: 18, Failures: 0, Errors: 0, Time elapsed: 0.125 sec
[junit] Running org.apache.asn1.ber.digester.RulesBaseTest
[junit] Tests run: 5, Failures: 0, Errors: 0, Time elapsed: 0.12 sec
[junit] Running org.apache.asn1.ber.digester.TagNodeTest
[junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.004 sec
[junit] Running org.apache.asn1.ber.TagTest
[junit] Tests run: 9, Failures: 0, Errors: 0, Time elapsed: 0.376 sec
[junit] Running org.apache.asn1.ber.DefaultMutableTupleNodeTest
[junit] Tests run: 28, Failures: 0, Errors: 0, Time elapsed: 0.044 sec
[junit] Running org.apache.asn1.ber.BERDecoderTest
[junit] Tests run: 11, Failures: 0, Errors: 0, Time elapsed: 0.043 sec
[junit] Running org.apache.asn1.ber.primitives.PrimitiveUtilsTest
[junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.105 sec
BUILD SUCCESSFUL
Total time: 13 seconds
Finished at: Sat Feb 19 03:12:28 CET 2005
> 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: asn1-ber.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
[jira] Commented: (DIRSNICKERS-103) Bad encoding of tags number above 127
Posted by "Emmanuel Lecharny (JIRA)" <di...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/DIRSNICKERS-103?page=comments#action_59385 ]
Emmanuel Lecharny commented on DIRSNICKERS-103:
-----------------------------------------------
Yep, Tuple.setTag(ByteBuffer, int) has a problem, too. I see what to do to correct it, but don't have time this morning to submit a patch for it. It will be done tonight GMT. Not a big deal, whatever, as no tags are above 30 ;-)
> 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
[jira] Assigned: (DIRSNICKERS-103) Bad encoding of tags number above 127
Posted by "Alan Cabrera (JIRA)" <di...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/DIRSNICKERS-103?page=history ]
Alan Cabrera reassigned DIRSNICKERS-103:
----------------------------------------
Assign To: Alan Cabrera (was: Alex Karasulu)
> 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: Alan Cabrera
> Priority: Minor
> Attachments: asn1-ber.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
[jira] Updated: (DIR-105) Bad encoding of tags number above 127
Posted by "Emmanuel Lecharny (JIRA)" <di...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/DIR-105?page=history ]
Emmanuel Lecharny updated DIR-105:
----------------------------------
Attachment: Tag.diff
TagTest.diff
Files that are to be modified :
.../directory/asn1/trunk/ber/src/java/org/apache/asn1/ber/Tag.java
.../directory/asn1/trunk/ber/src/test/org/apache/asn1/ber/TagTest.java
NB : Just launch the Junit Test ! I can't assure that this is bullet proof (my dev-env is quit messy actually)...
> Bad encoding of tags number above 127
> -------------------------------------
>
> Key: DIR-105
> URL: http://issues.apache.org/jira/browse/DIR-105
> Project: Directory
> Type: Bug
> 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
[jira] Resolved: (DIRSNICKERS-103) Bad encoding of tags number above 127
Posted by "Alan Cabrera (JIRA)" <di...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/DIRSNICKERS-103?page=history ]
Alan Cabrera resolved DIRSNICKERS-103:
--------------------------------------
Resolution: Fixed
Thanks Emmanuel!
> 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: Alan Cabrera
> Priority: Minor
> Attachments: asn1-ber.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
[jira] Commented: (DIRSNICKERS-103) Bad encoding of tags number above 127
Posted by "Alex Karasulu (JIRA)" <di...@incubator.apache.org>.
[ 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