jpos / jPOS

jPOS Project
http://jpos.org
GNU Affero General Public License v3.0
607 stars 460 forks source link

ISOBinaryFieldPackager doesn't check max length when packing variable length fields #611

Open hello-koval opened 2 weeks ago

hello-koval commented 2 weeks ago

https://github.com/jpos/jPOS/blob/d1f202f65353b4ea52f8347e32424dbdc8c35ca6/jpos/src/main/java/org/jpos/iso/ISOBinaryFieldPackager.java#L104

It looks like there should be a check for variable length fields too. E.g., if I created new IFB_LLLHBINARY( 9999, "xxx") packager, I would expect an exception when packing 10000 bytes.

ar commented 2 weeks ago

You're correct, in ISOStringFieldPackager we have:

    if (data.length() > getLength())
        throw new ISOException("Field length " + data.length() + " too long. Max: " + getLength());

no reason not to have it in the ISOBinaryFieldPackager counterpart.