* [PATCH] kconfig/nconf: Fix hang when editing symbol with a long prompt
@ 2016-11-24 22:10 Ben Hutchings
2016-12-11 11:32 ` Michal Marek
0 siblings, 1 reply; 2+ messages in thread
From: Ben Hutchings @ 2016-11-24 22:10 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: linux-kbuild
Currently it is impossible to edit the value of a config symbol with a
prompt longer than (terminal width - 2) characters. dialog_inputbox()
calculates a negative x-offset for the input window and newwin() fails
as this is invalid. It also doesn't check for this failure, so it
busy-loops calling wgetch(NULL) which immediately returns -1.
The additions in the offset calculations also don't match the intended
size of the window.
Limit the window size and calculate the offset similarly to
show_scroll_win().
Cc: stable <stable@vger.kernel.org>
Fixes: 692d97c380c6 ("kconfig: new configuration interface (nconfig)")
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
---
scripts/kconfig/nconf.gui.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c
index 8275f0e55106..4b2f44c20caf 100644
--- a/scripts/kconfig/nconf.gui.c
+++ b/scripts/kconfig/nconf.gui.c
@@ -364,12 +364,14 @@ int dialog_inputbox(WINDOW *main_window,
WINDOW *prompt_win;
WINDOW *form_win;
PANEL *panel;
- int i, x, y;
+ int i, x, y, lines, columns, win_lines, win_cols;
int res = -1;
int cursor_position = strlen(init);
int cursor_form_win;
char *result = *resultp;
+ getmaxyx(stdscr, lines, columns);
+
if (strlen(init)+1 > *result_len) {
*result_len = strlen(init)+1;
*resultp = result = realloc(result, *result_len);
@@ -386,14 +388,19 @@ int dialog_inputbox(WINDOW *main_window,
if (title)
prompt_width = max(prompt_width, strlen(title));
+ win_lines = min(prompt_lines+6, lines-2);
+ win_cols = min(prompt_width+7, columns-2);
+ prompt_lines = max(win_lines-6, 0);
+ prompt_width = max(win_cols-7, 0);
+
/* place dialog in middle of screen */
- y = (getmaxy(stdscr)-(prompt_lines+4))/2;
- x = (getmaxx(stdscr)-(prompt_width+4))/2;
+ y = (lines-win_lines)/2;
+ x = (columns-win_cols)/2;
strncpy(result, init, *result_len);
/* create the windows */
- win = newwin(prompt_lines+6, prompt_width+7, y, x);
+ win = newwin(win_lines, win_cols, y, x);
prompt_win = derwin(win, prompt_lines+1, prompt_width, 2, 2);
form_win = derwin(win, 1, prompt_width, prompt_lines+3, 2);
keypad(form_win, TRUE);
--
2.10.2
--
Ben Hutchings
Software Developer, Codethink Ltd.
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kconfig/nconf: Fix hang when editing symbol with a long prompt
2016-11-24 22:10 [PATCH] kconfig/nconf: Fix hang when editing symbol with a long prompt Ben Hutchings
@ 2016-12-11 11:32 ` Michal Marek
0 siblings, 0 replies; 2+ messages in thread
From: Michal Marek @ 2016-12-11 11:32 UTC (permalink / raw)
To: Ben Hutchings; +Cc: Yann E. MORIN, linux-kbuild
On Thu, Nov 24, 2016 at 10:10:23PM +0000, Ben Hutchings wrote:
> Currently it is impossible to edit the value of a config symbol with a
> prompt longer than (terminal width - 2) characters. dialog_inputbox()
> calculates a negative x-offset for the input window and newwin() fails
> as this is invalid. It also doesn't check for this failure, so it
> busy-loops calling wgetch(NULL) which immediately returns -1.
>
> The additions in the offset calculations also don't match the intended
> size of the window.
>
> Limit the window size and calculate the offset similarly to
> show_scroll_win().
>
> Cc: stable <stable@vger.kernel.org>
> Fixes: 692d97c380c6 ("kconfig: new configuration interface (nconfig)")
> Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Applied to kbuild.git#kconfig, thanks.
Michal
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-11 11:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-24 22:10 [PATCH] kconfig/nconf: Fix hang when editing symbol with a long prompt Ben Hutchings
2016-12-11 11:32 ` Michal Marek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.