Skip to content

Telnet rawq_getchar returns empty string #241

Open
@claytonsingh

Description

@claytonsingh

In the telnetlib.py file, the rawq_getchar function returns an empty string (b'') when self.rawq[self.irawq] evaluates to 0. This seems to be caused by the line of code:

c = self.rawq[self.irawq]
if not py2:
c = c.to_bytes((c.bit_length()+7)//8, 'big')

This issue appears to be related to the conversion of an integer value of 0 to bytes, which results in an empty byte string instead of a null byte character.

Steps to Reproduce:

Call rawq_getchar when self.rawq[self.irawq] is 0.
Observe that instead of returning the expected byte value, an empty string b'' is returned.

Expected Behavior:

When self.rawq[self.irawq] is 0, the method should ideally return a representation of the null byte (b'\x00').

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