sungsilnom / jsmpp

Automatically exported from code.google.com/p/jsmpp
Apache License 2.0
0 stars 0 forks source link

DefaultDecomposer.replaceSm(byte[] data) misses the registeredDelivery field #114

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
invoke the DefaultDecomposer.replaceSm(byte[] data) with a replaceSm message 
byte array.

What is the expected output? What do you see instead?
The expected output is a fully populated ReplaceSm object. The registered 
delivery field is missed by the method. This has the following consequences:
- The value of registered_delivery in the byte array gets read into the 
sm_default_msg_id on the ReplaceSm object.
- The value of sm_default_msg_id in the byte array gets read into the sm_length 
field on the ReplaceSm object. 
- An incorrect number of bytes (including the actual value of sm_length if 
sm_default_msg_id is greater than 0) is read into the short_message field
- The registered_delivery, sm_default_msg_id, sm_length and short_message 
fields on the ReplaceSm object end up with incorrect values.

What version of the product are you using? On what operating system?
2.1.0_2, Windows XP

Please provide any additional information below.
To fix, the following snippet of code from DefaultDecomposer.class:

req.setValidityPeriod(reader.readCString());        
StringValidator.validateString(req.getValidityPeriod(), 
StringParameter.VALIDITY_PERIOD);
req.setSmDefaultMsgId(reader.readByte());
byte smLength = reader.readByte();
req.setShortMessage(reader.readBytes(smLength));
StringValidator.validateString(req.getShortMessage(),
StringParameter.SHORT_MESSAGE);
return req;

should be replaced with:

req.setValidityPeriod(reader.readCString());        
StringValidator.validateString(req.getValidityPeriod(), 
StringParameter.VALIDITY_PERIOD);
req.setRegisteredDelivery(reader.readByte());
req.setSmDefaultMsgId(reader.readByte());
byte smLength = reader.readByte();
req.setShortMessage(reader.readBytes(smLength));
StringValidator.validateString(req.getShortMessage(),
StringParameter.SHORT_MESSAGE);
return req;

Original issue reported on code.google.com by joe.elle...@gmail.com on 18 Oct 2011 at 10:17