Negative Optional Parameter Length when buffer exceeds 255
Brought to you by:
tdtwister
I don't know if this has been patched in the latest release, but will report anyway.
Sent message_payload with buffer length greater than 254, from my SMPP app client. The receiving SMSC (which uses the same library) parses the length of the message_payload as negative.
It seems the encodeUnsigned(int positive) in class com.logica.smpp.pdu.ByteData was the culprit:
protected static short encodeUnsigned(int positive)
{
if (positive<32768) {
return (byte)positive;
} else {
return (short)(-(65536-positive));
}
}
It casts the parameter as byte, truncating the original value.
Hi, the correct way:
protected static short encodeUnsigned(int positive)
{
if (positive<32768) {
return (short)positive;
} else {
return (short)(-(65536-positive));
}
}