Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing padding field in marshalling and unmarshalling ElectronicEmitter #12

Closed
austinarrowsmith opened this issue Feb 10, 2021 · 2 comments

Comments

@austinarrowsmith
Copy link

If I understand correctly, I believe the ElectronicEmitter class is missing a 16-bit/2-byte padding field between numberOfBeams and emitterSystem that is missed during (un)marshalling (ref):

ie:

public int unmarshal(DataInputStream dis) throws Exception
{
    int uPosition = 0;
    try 
    {
        systemDataLength = (byte)dis.readUnsignedByte();
        uPosition += 1;
        numberOfBeams = (byte)dis.readUnsignedByte();
        uPosition += 1;
        dis.readUnsignedShort(); // missing this 2-byte padding buffer.
        uPosition += 2;
        uPosition += emitterSystem.unmarshal(dis);
        uPosition += location.unmarshal(dis);
        for(int idx = 0; idx < numberOfBeams; idx++)
.
.
.

... and in here:

public void marshal(java.nio.ByteBuffer byteBuffer) throws Exception
{
   byteBuffer.put( (byte)systemDataLength);
   byteBuffer.put( (byte)beams.size());
   byteBuffer.putShort((short)0); // needs to insert the (empty) padding field of the PDU.
   emitterSystem.marshal(byteBuffer);
   location.marshal(byteBuffer);
.
.
.

... and in the corresponding ByteBuffer methods for marshalling and unmarshalling too.

@terry-norbraten
Copy link
Collaborator

I have confirmed that the 16-bit padding field is indeed missing from both marshaling/unmarshaling methods in the ElectronicEmitter class.

@brutzman
Copy link
Contributor

@terry-norbraten confirmed corrected. Suggest adding comprehensive padding tests in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants