diff options
author | Peter Stephenson <p.stephenson@samsung.com> | 2023-05-25 15:47:23 +0100 |
---|---|---|
committer | Peter Stephenson <p.stephenson@samsung.com> | 2023-05-25 15:47:23 +0100 |
commit | 88eeade0bcdba8beb4a94534312b8febbc608697 (patch) | |
tree | 41cfcb1b1bf965f97b0b9ab8cae0bfa2d3f7caeb | |
parent | f80ad32c3f4e6239d9d6853d14ff36e28154f075 (diff) | |
download | zsh-88eeade0bcdba8beb4a94534312b8febbc608697.tar.gz zsh-88eeade0bcdba8beb4a94534312b8febbc608697.tar.xz zsh-88eeade0bcdba8beb4a94534312b8febbc608697.zip |
51739: detect invalid history word beginning
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | Src/hist.c | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog index 0b2993f7d..1a703ec04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2023-05-25 Peter Stephenson <p.stephenson@samsung.com> + + * 51739: Src/hist.c: detect invalid history word beginning. + 2023-05-21 Oliver Kiddle <opk@zsh.org> * 51769: Src/jobs.c, Src/utils.c: fix compilation when diff --git a/Src/hist.c b/Src/hist.c index 82d03a840..7e6394406 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -1643,12 +1643,17 @@ hend(Eprog prog) void ihwbegin(int offset) { + int pos = hptr - chline + offset; if (stophist == 2 || (histactive & HA_INWORD) || (inbufflags & (INP_ALIAS|INP_HIST)) == INP_ALIAS) return; if (chwordpos%2) chwordpos--; /* make sure we're on a word start, not end */ - chwords[chwordpos++] = hptr - chline + offset; + DPUTS1(pos < 0, "History word position < 0 in %s", + dupstrpfx(chline, hptr-chline)); + if (pos < 0) + pos = 0; + chwords[chwordpos++] = pos; } /* Abort current history word, not needed */ |