From: crquan@gmail.com
To: linux-kbuild@vger.kernel.org, Arnaud Lacombe <lacombar@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>, Michal Marek <mmarek@suse.cz>,
Nir Tzachar <nir.tzachar@gmail.com>,
Randy Dunlap <rdunlap@xenotime.net>,
linux-kernel@vger.kernel.org, c.rq541@comcast.net
Subject: [PATCH V3 2/5] scripts/kconfig/nconf: fix memmove's length arg
Date: Thu, 1 Sep 2011 10:52:19 -0700 [thread overview]
Message-ID: <1314899542-5848-2-git-send-email-crquan@gmail.com> (raw)
In-Reply-To: <1314899542-5848-1-git-send-email-crquan@gmail.com>
From: Cheng Renquan <crquan@gmail.com>
In case KEY_BACKSPACE / KEY_DC to delete a char, it memmove only
(len-cursor_position+1) bytes;
the default case is to insert a char, it should also memmove exactly
(len-cursor_position+1) bytes;
the original use of (len+1) is wrong and may access following memory
that doesn't belong to result, may cause SegFault in theory;
case KEY_BACKSPACE:
if (cursor_position > 0) {
memmove(&result[cursor_position-1],
&result[cursor_position],
len-cursor_position+1);
cursor_position--;
}
break;
case KEY_DC:
if (cursor_position >= 0 && cursor_position < len) {
memmove(&result[cursor_position],
&result[cursor_position+1],
len-cursor_position+1);
}
break;
default:
if ((isgraph(res) || isspace(res)) &&
len-2 < result_len) {
/* insert the char at the proper position */
memmove(&result[cursor_position+1],
&result[cursor_position],
len-cursor_position+1);
result[cursor_position] = res;
cursor_position++;
}
Signed-off-by: Cheng Renquan <crquan@gmail.com>
Acked-by: Nir Tzachar <nir.tzachar@gmail.com>
---
scripts/kconfig/nconf.gui.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c
index d3af04e..3ce2a7c 100644
--- a/scripts/kconfig/nconf.gui.c
+++ b/scripts/kconfig/nconf.gui.c
@@ -457,7 +457,7 @@ int dialog_inputbox(WINDOW *main_window,
/* insert the char at the proper position */
memmove(&result[cursor_position+1],
&result[cursor_position],
- len+1);
+ len-cursor_position+1);
result[cursor_position] = res;
cursor_position++;
} else {
--
1.7.6
next prev parent reply other threads:[~2011-09-01 17:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-29 9:09 [RFC] nconf bug fixes and improvements Cheng Renquan
2011-08-29 14:14 ` Arnaud Lacombe
2011-08-29 16:12 ` Randy Dunlap
2011-08-29 16:53 ` Sam Ravnborg
2011-09-01 17:52 ` [PATCH V3 1/5] scripts/kconfig/nconf: fix typo: unknow => unknown crquan
2011-09-01 17:52 ` crquan [this message]
2011-09-01 17:52 ` [PATCH V3 3/5] scripts/kconfig/nconf: dynamically alloc dialog_input_result crquan
2011-09-01 17:52 ` [PATCH V3 4/5] scripts/kconfig/nconf: fix editing long strings crquan
2011-09-01 17:52 ` [PATCH V3 5/5] scripts/kconfig/nconf: add KEY_HOME / KEY_END for dialog_inputbox crquan
2011-09-09 12:46 ` Michal Marek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1314899542-5848-2-git-send-email-crquan@gmail.com \
--to=crquan@gmail.com \
--cc=c.rq541@comcast.net \
--cc=lacombar@gmail.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mmarek@suse.cz \
--cc=nir.tzachar@gmail.com \
--cc=rdunlap@xenotime.net \
--cc=sam@ravnborg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome