[rtems commit] main_edit.c: Do not reference beyond end of array
Joel Sherril
joel at rtems.org
Tue Nov 25 20:40:34 UTC 2014
Module: rtems
Branch: master
Commit: 3bd0cd1ad574ead8fe5c5bc58d62089652a02606
Changeset: http://git.rtems.org/rtems/commit/?id=3bd0cd1ad574ead8fe5c5bc58d62089652a02606
Author: Joel Sherrill <joel.sherrill at oarcorp.com>
Date: Mon Nov 24 13:54:26 2014 -0600
main_edit.c: Do not reference beyond end of array
---
cpukit/libmisc/shell/main_edit.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/cpukit/libmisc/shell/main_edit.c b/cpukit/libmisc/shell/main_edit.c
index 212b212..2ede21b 100644
--- a/cpukit/libmisc/shell/main_edit.c
+++ b/cpukit/libmisc/shell/main_edit.c
@@ -815,6 +815,11 @@ static int getachar(void)
#if KEY_HISTORY
if (key_history_in < sizeof(key_history)) {
key_history[key_history_in++] = ch;
+#if defined(__rtems__)
+ } if (key_history_in > sizeof(key_history)) {
+ /* eliminate possibility of using index above array bounds */
+ assert( key_history_in > sizeof(key_history));
+#endif
} else {
memmove(&key_history[0], &key_history[1], sizeof(key_history) - sizeof(key_history[0]));
key_history[key_history_in - 1] = ch;
More information about the vc
mailing list