question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

0 length Ber TLV tag got drop when using BerTlvBuilder

See original GitHub issue

Hi, thanks for your great library. I’ve some issue with building nested BerTLV tag. The following is working as expected :

BerTlv tlv = new BerTlv(new BerTag(0x01),new byte[]{0x06});
BerTlv some = new BerTlvBuilder()
       .addBytes(new BerTag(0xE3), new BerTlvBuilder().addBerTlv(tlv).buildArray())
       .buildTlv();

which gives :

010106
E303010106

But when using 0 length BerTLV tag, the following is not working

BerTlv tlv = new BerTlv(new BerTag(0x01),new byte[]{});
BerTlv some = new BerTlvBuilder()
       .addBytes(new BerTag(0xE3), new BerTlvBuilder().addBerTlv(tlv).buildArray())
       .buildTlv();

I get :

0100
E300

But I’m expecting :

0100
E3020100

Thanks for your help

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
evsinevcommented, Nov 13, 2017

@bertrandmartel Great. I’ve just release 1.0-8 version. It’ll be available in a hour once sonatype will promote it to maven-central.

1reaction
evsinevcommented, Nov 12, 2017

I’ve got your point. I thought that you use BerTlvBuilder.buildArray() to create an array.

You are right BerTlvBuilder.buildTlv() returns wrong elements. It skips tags with an empty length.

I’ll fix it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why BER-TLV "DF9A" tag is recognized as "invalid"?
I have problem with understanding why all the BER ...
Read more >
com.payneteasy.tlv.BerTlvBuilder java code examples - Tabnine
public BerTlvBuilder add(BerTlvBuilder aBuilder) { byte[] array = aBuilder.buildArray(); System.arraycopy(array, 0, theBuffer, thePos, array.length); ...
Read more >
PrimitiveBERTLV (Java Card API, Classic Edition)
Writes a primitive TLV representation to the specified byte array using as input a Primitive BER tag representation in a byte array and...
Read more >
Basic Encoding Rules (BER) class for embedded system
Ber (uint8_t tag, unsigned short length=0, const uint8_t ... should get a crash if trying to free data allocated with new[] using delete...
Read more >
com.payneteasy.tlv.BerTlvBuilder Maven / Gradle / Ivy
Search and download functionalities are using the official Maven repository. ... buffer, 0, buffer.length); } public BerTlvBuilder addBytes(BerTag aObject ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found