summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2014-11-24 13:54:26 -0600
committerJoel Sherrill <joel.sherrill@oarcorp.com>2014-11-25 12:58:00 -0600
commit3bd0cd1ad574ead8fe5c5bc58d62089652a02606 (patch)
tree7f27cd7fa55a7aa92b8e657bf9aca652fd7b691b
parentshell/main_edit.c: Note return value not checked (diff)
downloadrtems-3bd0cd1ad574ead8fe5c5bc58d62089652a02606.tar.bz2
main_edit.c: Do not reference beyond end of array
-rw-r--r--cpukit/libmisc/shell/main_edit.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/cpukit/libmisc/shell/main_edit.c b/cpukit/libmisc/shell/main_edit.c
index 212b212987..2ede21bc36 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;