« Previous | Next » 

Revision 8af42882

ID8af42882a51c632a14d77277df0740f1aa8c958a

Added by Markus Armbruster over 12 years ago

readline: Fix buffer overrun on re-add to history

readline_hist_add() moves the history entry to the end of history. It
uses memmove() to move rs->history[idx + 1..] to rs->history[idx..].
However, its size argument is off by two array elements, so it writes
one element beyond rs->history[], and reads two.

On my system, this clobbers rs->hist_entry and the hole right after
it. Since the function assigns to rs->hist_entry in time, the bug has
no ill effects for me.

Spotted by Coverity.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Stefan Hajnoczi <>

Files

  • added
  • modified
  • copied
  • renamed
  • deleted

View differences