Skip to content

The trailing ";" may not be removed from the buffer in handleData (formerly receiveBytes) #72

Open

Description

@Poikilos

I don't quite understand why handleData (formerly receiveBytes):

self.inboundBuffer = self.inboundBuffer[lastByte:]

Is this is type-o? Maybe it should be self.inboundBuffer = self.inboundBuffer[lastByte+1:] if lastByte is at ";"

I'm not sure because for some reason the loop starts at 2 (for offset in range(2, 9+1):), almost like it assumes the buffer always starts with ";" which seems fragile and possibly will lose the first packet in a session.

Activity

  1. bobjacobsen commented on Jan 7, 2026

    @bobjacobsen
    Owner

    Not sure I understand the second point.

    The for offset in range(2, 9+1): loop is indexing through the locations that carry the identifier field. The 2 is because the identifier field is preceded by ':S' at the start of the frame: The ':' was previously found in an if statement and sets the 0 point as being at the index of that.

    As the comment just above self.inboundBuffer = self.inboundBuffer[lastByte:] says, "lastByte is index of ; in this message". So that could probably be lastByte+1 in the self.inboundBuffer assignment. But that's not going to lose a packet?

  2. bobjacobsen commented on Jan 7, 2026

    @bobjacobsen
    Owner

    That should have said ':X' at the start of the frame, I think.

  3. Poikilos commented on Jan 8, 2026

    @Poikilos
    ContributorAuthor

    Not sure I understand the second point.

    The for offset in range(2, 9+1): loop is indexing through the locations that carry the identifier field. The 2 is because the identifier field is preceded by ':S' at the start of the frame: The ':' was previously found in an if statement and sets the 0 point as being at the index of that.

    Ok I managed to figure that out today

    :X

    yes

    As the comment just above self.inboundBuffer = self.inboundBuffer[lastByte:] says, "lastByte is index of ; in this message". So that could probably be lastByte+1 in the self.inboundBuffer assignment. But that's not going to lose a packet?

    It will leave ";" in the buffer, so next time there will be a ";" before the following ":", but the code never looks before ":" so it is ok, no packet loss. Ok I can improve it to make the code more explicit though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions