From d5465452939e0999c189413da208f0de41ba1f87 Mon Sep 17 00:00:00 2001 From: Torsten Rasmussen Date: Mon, 15 Mar 2021 17:05:22 +0100 Subject: [PATCH] Handle NULL character as input properly Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/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 `-@` / `-2`. Signed-off-by: Torsten Rasmussen Signed-off-by: Jim Huang --- menuconfig.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/menuconfig.py b/menuconfig.py index 4b32d40..253869f 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -1762,6 +1762,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()) @@ -2201,6 +2204,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)