The variable datum object only serialises the actual data, but recieved pdus will be parsed as though padding has been sent as well.
This results in the variable datum object ignoring several of the bits it recieves, and attempting to read more from
the input stream than has been sent.
Issue in code:
(code from line 3579 of dis7.py, my comments start with #########)
def serialize(self, outputStream):
"""serialize the class """
outputStream.write_unsigned_int(self.variableDatumID);
outputStream.write_unsigned_int(self.variableDatumLength);
for x in range(self.variableDatumLength // 8): # length is in bits
outputStream.write_byte(self.variableData[x])
######### no padding is sent, only data from variableData within the size of variableDatumLength field
def parse(self, inputStream):
""""Parse a message. This may recursively call embedded objects."""
self.variableDatumID = inputStream.read_unsigned_int();
self.variableDatumLength = inputStream.read_unsigned_int();
for x in range(self.variableDatumLength // 8): # length is in bits
self.variableData.append(inputStream.read_byte());
######## the parse function expects padding
# Skip over padding
# "This field shall be padded at the end to make the length a multiple of 64-bits."
for x in range(self.datumPaddingSizeInBits() // 8):
inputStream.read_byte()
Expected behaviour:
The serialise function should send a number of zeros corresponding to the padding size of the datum.
Fix:
This isssue could be fixed by adding the following code to the end of the serialize function:
for x in range(self.datumPaddingSizeInBits() // 8):
inputStream.write_byte(0)
The variable datum object only serialises the actual data, but recieved pdus will be parsed as though padding has been sent as well. This results in the variable datum object ignoring several of the bits it recieves, and attempting to read more from the input stream than has been sent.
Issue in code:
(code from line 3579 of dis7.py, my comments start with #########)
Expected behaviour:
The serialise function should send a number of zeros corresponding to the padding size of the datum.
Fix:
This isssue could be fixed by adding the following code to the end of the serialize function: