Commit graph

18 commits

Author SHA1 Message Date
Martin Dvorak
64b96d478a Adding ability to inject command to terminal. 2021-12-02 22:52:13 +01:00
Thibault Charbonnier
5ab8205859
Fix of wrong zsh extended history (with timestamps) SEGFAULT and parsing #409 (#410)
This patch fixes a segfault when .zsh_history contains commands starting
with `:` and longer than 15 characters long.

Considering the history line:

    : 1592444398:0;:vspman epoll_ctl

The ranked item's line will be:

    :vspman epoll_ctl

When building the prioritized history, we used to apply the zsh extended
history offset if the line starts with `:` (and if the command is longer
than `15`, defined by `ZSH_HISTORY_ITEM_OFFSET`), which then makes the
item point to:

    tl

This makes the `r->item` pointer invalid, which causes the segfault
observed in #408 within `prioritized_history_destroy`.

---

This patch prevents the same issue from arising again (even if the
line is wrongly interpreted) since it avoids any pointer arithmetic
between assignment and freeing.

Additionally, the patch also greatly improves the heuristics used in
determining whether a line is of extended history format or not, since
the non-extended format is also supported by zsh.

---

Fix #410
Fix #399
2020-11-19 07:13:30 +01:00
Martin Dvorak
4976bab73f Polishing sources (copyrights, test refactoring). 2019-12-21 07:53:11 +01:00
Martin Dvorak
989ea7039f hh2hstr finishing script fixes #309 2018-08-26 07:17:40 +02:00
Martin Dvorak
1dbfdb4758 hh2hstr fixing tests #309 2018-08-26 07:17:35 +02:00
Martin Dvorak
4c46770566 HSTR/HH reconciliation in tests. 2018-08-21 17:46:45 +02:00
Martin Dvorak
52726718e4 HH > HSTR rollback. 2018-08-21 17:31:56 +02:00
Martin Dvorak
3d90d463b1 hstr / hh reconciliation. 2018-08-21 11:31:27 +02:00
Martin Dvorak
9ef36c0782 Trimming string matched by regexp on its selection + test which resolves #228 2018-08-20 23:18:46 +02:00
Martin Dvorak
470eca3047 Leaks: fixing test data for valgrind #68 2018-08-17 20:53:54 +02:00
Martin Dvorak
fa7622ae1b Leaks: non-interactive HSTR w/ EMPTY history has NO leaks 2018-08-17 20:51:33 +02:00
Martin Dvorak
64d39992a5 Introducing long lines elide w/ unit tests which resolves #149. 2018-08-13 17:04:31 +02:00
Martin Dvorak
16629ca926 Fixing getopt unit test asserts. 2018-08-13 17:02:53 +02:00
Martin Dvorak
b51d5f2e25 Finishing refactoring of standalone tests to unit tests. 2018-08-13 17:02:53 +02:00
Martin Dvorak
f73da7dd18 Adding hashset unit tests, introducing unit tests scripts, refactoring old scripts and test code. 2018-08-13 17:02:53 +02:00
Martin Dvorak
ade822ff4a Adding Unity C test framework. 2018-08-13 17:02:53 +02:00
Martin Dvorak
742c51c756 Introducing new main() to enable creation of UNIT tests. 2018-08-13 17:02:53 +02:00
Martin Dvorak
14d2e8ddc1 Tarball build script done. 2018-08-13 16:59:59 +02:00