Skip to content

Spurious error decoding multi-byte output from ShellSession #168

Description

@christian-intra2net

We are using avocado to test our email filtering pipeline. We find lots of test files by running a "find" command on the VM through a RemoteSession and then perfom tests with each of these. One of the test files' name contains lots of traditional Chinese characters and sometimes there were errors only with that file. We spent quite some time to notice that the filename is not always transferred correctly from the VM to the calling host: sometimes one of the file's characters is just missing.

Further investigation revealed the problem in the ShellSession's decoding: it reads up to 1024 bytes from the VM, decodes those, and appends the decoded characters to the complete output, ignoring errors. If the output size is larger than 1024 bytes, and the 1023rd byte happens to be the first or second of the Chinese character bytes (each character requires 3 bytes in our utf8-environment), then decoding fails silently and that one character is missing from the transferred text.

The same erroneous decoding happens in Tail._tail. I have created a reproducer, which hopefully clarifies the problem:

encoding_test.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions