Skip to content

_parse_read_response does not raise an exception in case of a SystemEvent #827

Description

@bvanelli

See #775 (comment)

Incorrect framing can cause a V254 SystemEvent and it this gets completely swallowed by the library at _parse_read_response because it thinks this is a valid response and does not raise an SystemEvent exception.

Here is the reproduction:

# blob A - correct request framing
A = b"\x00\x01\x00\x12\x02\x05\x00\xe0\x00\x00\x07\x00\x00\x00\x00"

# blob B - incorrect request framing (the SystemEvent)
B = bytes.fromhex(
    "00000000000001d10000000000000000000000170000"
    "9d6c00009d6d000000080000000200009d6e00000004"
    "70000e5200009d6f00000004"
    "0000054c00009d7000000003000500009d7100000009"
    "a2013b000294ff8800009d720000000400000000"
    "00009d730000000400" "00054c00009d74000000040000"
    "04b600009d75000000040000000000009d7600000003"
    "000900009d770000000300000000" "9d78000000031000"
    "00009d79000000031012" "00009d7a0000000308010000"
    "9d7b0000000300" "0e00000000"
)

from s7commplus.client import _parse_read_response

_parse_read_response(A)  # -> [b'\x02\x05\x00\xe0']
_parse_read_response(B)  # -> []   <-- the bug: silent, 195 bytes discarded

On read_symbolic (during a browse), this causes it to raise the RuntimeError.

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