-
Notifications
You must be signed in to change notification settings - Fork 117
Various parser crashes on random input #209
Copy link
Copy link
Open
Description
Looks like there are multiple bugs in streams.py and screens.py that cause crashes when feeding random terminal input.
I was testing something, so I created a 100MB file with random content:
dd if=/dev/random of=bigfile bs=1024 count=102400Then I was feeding this to the input of the stream. Multiple errors occured:
TypeError: insert_lines() got an unexpected keyword argument 'private'
File ".../site-packages/pyte/streams.py", line 205, in feed
taking_plain_text = send(data[offset:offset + 1])
File ".../site-packages/pyte/streams.py", line 213, in _send_to_parser
return self._parser.send(data)
~~~~~~~~~~~~~~~~~^^^^^^
File ".../site-packages/pyte/streams.py", line 347, in _parser_fsm
params.append(min(int(current or 0), 9999))
~~~^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '³' File ".../site-packages/pyte/streams.py", line 205, in feed
taking_plain_text = send(data[offset:offset + 1])
File ".../site-packages/pyte/streams.py", line 213, in _send_to_parser
return self._parser.send(data)
~~~~~~~~~~~~~~~~~^^^^^^
File ".../site-packages/pyte/streams.py", line 355, in _parser_fsm
csi_dispatch[char](*params)
~~~~~~~~~~~~~~~~~~^^^^^^^^^
TypeError: cursor_down() takes from 1 to 2 positional arguments but 3 were givenThere were others. I don't think it makes sense to list them all. But I guess it would be good at some point to either run a fuzzer over the parser, or feed huge random files until it doesn't crash anymore on any input.
Note: this is not an hypothetical issue. Anyone can cat some/binary/file into the terminal.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels