From d516838ea7dd0cf32f3efee76057332a8e92a596 Mon Sep 17 00:00:00 2001 From: Torsten Rasmussen Date: Mon, 15 Mar 2021 14:55:27 +0100 Subject: [PATCH] scripts: menuconfig: proper handling of NULL character as input Fixes: #33212 Upstream PR: https://github.com/ulfalizer/Kconfiglib/pull/103 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 --- scripts/kconfig/menuconfig.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/kconfig/menuconfig.py b/scripts/kconfig/menuconfig.py index 9b159eb087c0..b0069eee1251 100755 --- a/scripts/kconfig/menuconfig.py +++ b/scripts/kconfig/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)