kernel_optimize_test/scripts/kconfig
Mihai Moldovan cc1956f8b2 kconfig: nconf: stop endless search loops
[ Upstream commit 8c94b430b9f6213dec84e309bb480a71778c4213 ]

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-19 10:12:56 +02:00
..
lxdialog kconfig: remove trailing whitespaces 2019-05-09 22:37:17 +09:00
tests kconfig: tests: remove randconfig test for choice in choice 2020-05-12 13:28:30 +09:00
.gitignore kconfig: qconf: compile moc object separately 2020-08-01 20:54:39 +09:00
conf.c kconfig: Add yes2modconfig and mod2yesconfig targets. 2020-01-07 02:18:45 +09:00
confdata.c kconfig: Invalidate all symbols after changing to y or m. 2020-02-05 13:45:37 +09:00
expr.c kconfig: distinguish between dependencies and visibility in help text 2020-01-07 02:18:45 +09:00
expr.h kconfig: distinguish between dependencies and visibility in help text 2020-01-07 02:18:45 +09:00
gconf-cfg.sh
gconf.c kconfig: fix an "implicit declaration of function" warning 2020-01-10 02:44:54 +09:00
gconf.glade
images.c kconfig: constify XPM data 2020-08-14 13:30:03 +09:00
images.h kconfig: constify XPM data 2020-08-14 13:30:03 +09:00
lexer.l kconfig: add 'static' to some file-local data 2020-08-14 13:30:04 +09:00
list.h
lkc_proto.h kconfig: qconf: fix incomplete type 'struct gstr' warning 2020-09-20 12:58:49 +09:00
lkc.h kconfig: qconf: fix incomplete type 'struct gstr' warning 2020-09-20 12:58:49 +09:00
Makefile Revert "kconfig: remove 'kvmconfig' and 'xenconfig' shorthands" 2021-01-23 16:03:57 +01:00
mconf-cfg.sh kconfig: be more helpful if pkg-config is missing 2019-11-11 20:10:01 +09:00
mconf.c kconfig: fix an "implicit declaration of function" warning 2020-01-10 02:44:54 +09:00
menu.c kconfig: do not assign a variable in the return statement 2020-05-12 13:28:30 +09:00
merge_config.sh merge_config.sh: ignore unwanted grep errors 2019-09-04 23:12:50 +09:00
nconf-cfg.sh kconfig: be more helpful if pkg-config is missing 2019-11-11 20:10:01 +09:00
nconf.c kconfig: nconf: stop endless search loops 2021-05-19 10:12:56 +02:00
nconf.gui.c kconfig/[mn]conf: handle backspace (^H) key 2019-03-29 22:48:01 +09:00
nconf.h kconfig: convert to SPDX License Identifier 2018-12-28 22:22:28 +09:00
parser.y kconfig: allow only 'config', 'comment', and 'if' inside 'choice' 2020-05-12 13:28:30 +09:00
preprocess.c kconfig: fix return value of do_error_if() 2020-12-30 11:54:01 +01:00
qconf-cfg.sh
qconf.cc kconfig: qconf: create QApplication after option checks 2020-09-25 00:37:13 +09:00
qconf.h kconfig: qconf: remove Y, M, N columns 2020-09-25 00:37:13 +09:00
streamline_config.pl kconfig: streamline_config.pl: check defined(ENV variable) before using it 2020-09-03 12:16:30 +09:00
symbol.c kconfig: add 'static' to some file-local data 2020-08-14 13:30:04 +09:00
util.c kconfig: convert to SPDX License Identifier 2018-12-28 22:22:28 +09:00