linux-stable/scripts/kconfig
Mihai Moldovan df75b62905 kconfig: nconf: stop endless search loops
[ Upstream commit 8c94b430b9 ]

If the user selects the very first entry in a page and performs a
search-up operation, or selects the very last entry in a page and
performs a search-down operation that will not succeed (e.g., via
[/]asdfzzz[Up Arrow]), nconf will never terminate searching the page.

The reason is that in this case, the starting point will be set to -1
or n, which is then translated into (n - 1) (i.e., the last entry of
the page) or 0 (i.e., the first entry of the page) and finally the
search begins. This continues to work fine until the index reaches 0 or
(n - 1), at which point it will be decremented to -1 or incremented to
n, but not checked against the starting point right away. Instead, it's
wrapped around to the bottom or top again, after which the starting
point check occurs... and naturally fails.

My original implementation added another check for -1 before wrapping
the running index variable around, but Masahiro Yamada pointed out that
the actual issue is that the comparison point (starting point) exceeds
bounds (i.e., the [0,n-1] interval) in the first place and that,
instead, the starting point should be fixed.

This has the welcome side-effect of also fixing the case where the
starting point was n while searching down, which also lead to an
infinite loop.

OTOH, this code is now essentially all his work.

Amazingly, nobody seems to have been hit by this for 11 years - or at
the very least nobody bothered to debug and fix this.

Signed-off-by: Mihai Moldovan <ionic@ionic.de>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-05-22 10:57:37 +02:00
..
lxdialog kconfig/[mn]conf: handle backspace (^H) key 2019-05-04 09:15:22 +02:00
.gitignore Remove gperf usage from toolchain 2017-08-19 11:02:53 -07:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
POTFILES.in
check.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
conf.c kconfig: allow kconfig to handle longer path names 2015-12-10 11:06:10 +01:00
confdata.c kconfig: fix broken dependency in randconfig-generated .config 2020-02-28 16:35:59 +01:00
expr.c kconfig: don't crash on NULL expressions in expr_eq() 2020-01-12 12:11:58 +01:00
expr.h Kconfig: Introduce the "imply" keyword 2016-11-16 09:26:33 +01:00
gconf.c gconfig: remove misleading parentheses around a condition 2017-03-22 02:56:33 +09:00
gconf.glade
images.c
kconf_id.c Remove gperf usage from toolchain 2017-08-19 11:02:53 -07:00
kxgettext.c
list.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
lkc.h Remove gperf usage from toolchain 2017-08-19 11:02:53 -07:00
lkc_proto.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mconf.c kconfig: Do not print status messages in make -s mode 2015-04-09 17:44:34 +02:00
menu.c kconfig: Fix automatic menu creation mem leak 2018-04-26 11:02:08 +02:00
merge_config.sh kconfig/merge_config.sh: Accept a single file 2015-10-14 16:19:37 +02:00
nconf.c kconfig: nconf: stop endless search loops 2021-05-22 10:57:37 +02:00
nconf.gui.c kconfig/[mn]conf: handle backspace (^H) key 2019-05-04 09:15:22 +02:00
nconf.h
qconf.cc xconfig: fix missing suboption and help panels on first run 2016-12-11 21:40:54 +01:00
qconf.h Port xconfig to Qt5 - Source format. 2015-10-14 14:59:03 +02:00
streamline_config.pl scripts: Switch to more portable Perl shebang 2017-05-14 11:20:44 +09:00
symbol.c Kconfig: Introduce the "imply" keyword 2016-11-16 09:26:33 +01:00
util.c
zconf.l kconfig: fix memory leak when EOF is encountered in quotation 2019-01-26 09:37:04 +01:00
zconf.lex.c_shipped kconfig: Regenerate shipped zconf.{hash,lex}.c files 2015-08-19 17:05:39 +02:00
zconf.tab.c_shipped Remove gperf usage from toolchain 2017-08-19 11:02:53 -07:00
zconf.y kconfig: fix the rule of mainmenu_stmt symbol 2018-11-04 14:52:45 +01:00