Skip to content

Commit

Permalink
scripts: menuconfig: proper handling of NULL character as input
Browse files Browse the repository at this point in the history
Fixes: zephyrproject-rtos/zephyr#33212

Ignoring when user inputs NULL in a text field.
menuconfig exits with a python stack trace if NULL is provided as input
character, therefore ignore NULL as an input character to prevent this
behaviour.

A NULL character may be given accidentally by the user through the
following ways:
- Pressing `Win` key on keyboard (Windows only)
- Pressing `<CTRL>-@` / `<CTRL>-2`.

Signed-off-by: Torsten Rasmussen <[email protected]>
  • Loading branch information
tejlmand committed Mar 15, 2021
1 parent 061e71f commit 12b2d61
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions menuconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -1757,6 +1757,9 @@ def edit_width():
_safe_curs_set(0)
return None

elif c == "\0": # \0 = NUL, ignore
pass

else:
s, i, hscroll = _edit_text(c, s, i, hscroll, edit_width())

Expand Down Expand Up @@ -2196,6 +2199,9 @@ def select_prev_match():
elif c == curses.KEY_HOME:
sel_node_i = scroll = 0

elif c == "\0": # \0 = NUL, ignore
pass

else:
s, s_i, hscroll = _edit_text(c, s, s_i, hscroll,
_width(edit_box) - 2)
Expand Down

0 comments on commit 12b2d61

Please sign in to comment.