aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2021-01-04 15:02:53 +0000
committerPeter Maydell <peter.maydell@linaro.org>2021-01-04 15:02:53 +0000
commite551455f1e7a3d7eee9e11e2903e4050bc5511ae (patch)
tree13d7ce0d638b9e9f578c3192dbde7cd9002ea87b
parent41192db338588051f21501abc13743e62b0a5605 (diff)
parent593621f36b716eb091c4ec791db72dd4461789da (diff)
Merge remote-tracking branch 'remotes/stefanha-gitlab/tags/block-pull-request' into staging
Pull request # gpg: Signature made Mon 04 Jan 2021 14:22:58 GMT # gpg: using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full] # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" [full] # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8 * remotes/stefanha-gitlab/tags/block-pull-request: readline: Fix possible array index out of bounds in readline_hist_add() Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--util/readline.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/util/readline.c b/util/readline.c
index e534460da6..f1ac6e4769 100644
--- a/util/readline.c
+++ b/util/readline.c
@@ -240,6 +240,9 @@ static void readline_hist_add(ReadLineState *rs, const char *cmdline)
}
if (strcmp(hist_entry, cmdline) == 0) {
same_entry:
+ if (idx == READLINE_MAX_CMDS - 1) {
+ return;
+ }
new_entry = hist_entry;
/* Put this entry at the end of history */
memmove(&rs->history[idx], &rs->history[idx + 1],