TLVMsg bug?

View: New views
2 Messages — Rating Filter:   Alert me  

TLVMsg bug?

by tommy-35 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


-- My.java --
TLVList list = new TLVList();
list.append(new TLVMsg(0x01, "8001".getBytes()));
-- throw exception:
Exception in thread "main" java.lang.RuntimeException: Uneven
number(1) of hex digits passed to hex2byte.
        at org.jpos.iso.ISOUtil.hex2byte(ISOUtil.java:635)
        at org.jpos.tlv.TLVMsg.getTLV(TLVMsg.java:70)
        at org.jpos.tlv.TLVList.pack(TLVList.java:184)


-- 1.6.0: TLVMsg.java getTLV() --
69  String hexVal = Integer.toHexString(tag);
70  byte[] bTag = ISOUtil.hex2byte(hexVal);
is a bug?

-- Fix:  TLVMsg.java getTLV() --
69  String hexVal = Integer.toHexString(tag);
70  hexVal = (hexVal.length()==1) ? "0"+hexVal : hexVal;  // check
hexVal.length()
71  byte[] bTag = ISOUtil.hex2byte(hexVal);
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To post to this group, send email to jpos-users@...
To unsubscribe from this group, send email to jpos-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/jpos-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: TLVMsg bug?

by Alejandro Revilla :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


This is certainly a bug and I think the best way to fix it is to just
left pad un-even hex strings in ISOUtil.hex2byte, it would play prevent
defense on future issues like this.

any taker? (I'm out of the country now with a tight schedule)

On Thu, Jul 03, 2008 at 02:03:27AM -0700, tommy wrote:

>
> -- My.java --
> TLVList list = new TLVList();
> list.append(new TLVMsg(0x01, "8001".getBytes()));
> -- throw exception:
> Exception in thread "main" java.lang.RuntimeException: Uneven
> number(1) of hex digits passed to hex2byte.
> at org.jpos.iso.ISOUtil.hex2byte(ISOUtil.java:635)
> at org.jpos.tlv.TLVMsg.getTLV(TLVMsg.java:70)
> at org.jpos.tlv.TLVList.pack(TLVList.java:184)
>
>
> -- 1.6.0: TLVMsg.java getTLV() --
> 69  String hexVal = Integer.toHexString(tag);
> 70  byte[] bTag = ISOUtil.hex2byte(hexVal);
> is a bug?
>
> -- Fix:  TLVMsg.java getTLV() --
> 69  String hexVal = Integer.toHexString(tag);
> 70  hexVal = (hexVal.length()==1) ? "0"+hexVal : hexVal;  // check
> hexVal.length()
> 71  byte[] bTag = ISOUtil.hex2byte(hexVal);
> >

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To post to this group, send email to jpos-users@...
To unsubscribe from this group, send email to jpos-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/jpos-users?hl=en
-~----------~----~----~----~------~----~------~--~---

LightInTheBox - Buy quality products at wholesale price