Skip to content

Error in util.Set_String and util.Get_String #479

@PoitrasJ

Description

@PoitrasJ

When reading the first Byte in the ByteArray, which contains the maximum length of the string, the Hexadecimal value is sometimes in a format that Python will not cast to Integer : b'\ff' will stay the type "Bytes" and the slice access fails.

this Section in set_string

    # fill the rest with empty space
    for r in range(i + 1, (bytearray_[byte_index]) - 2):
        bytearray_[byte_index + 2 + r] = ord(' ')

this Section in get_string

    str_length = int(bytearray_[byte_index + 1])
    max_string_size = int(bytearray_[byte_index])

The solution i came up is to evaluate the value using ord :

    # fill the rest with empty space
    for r in range(i + 1, ord(bytearray_[byte_index]) - 2):
        bytearray_[byte_index + 2 + r] = ord(' ')
    str_length = ord(bytearray_[byte_index + 1])
    max_string_size = ord(bytearray_[byte_index])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions