From 12b2d61a68877cdccf453074aaa6fc07a2afc206 Mon Sep 17 00:00:00 2001 From: Torsten Rasmussen Date: Mon, 15 Mar 2021 17:05:22 +0100 Subject: [PATCH] scripts: menuconfig: proper handling of NULL character as input 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 --- menuconfig.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/menuconfig.py b/menuconfig.py index 7e765d36..a0ab0045 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -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()) @@ -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)