hstr/test
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
..
resources HSTR/HH reconciliation in tests. 2018-08-21 17:46:45 +02:00
src Fix of wrong zsh extended history (with timestamps) SEGFAULT and parsing #409 (#410) 2020-11-19 07:13:30 +01:00
unity/src Adding Unity C test framework. 2018-08-13 17:02:53 +02:00
.gitignore Polishing sources (copyrights, test refactoring). 2019-12-21 07:53:11 +01:00
hstr-unit-tests.pro Fix of wrong zsh extended history (with timestamps) SEGFAULT and parsing #409 (#410) 2020-11-19 07:13:30 +01:00
test-bug-124.sh Polishing sources (copyrights, test refactoring). 2019-12-21 07:53:11 +01:00
test-bug-163.sh Polishing sources (copyrights, test refactoring). 2019-12-21 07:53:11 +01:00
test-bug-175.sh Polishing sources (copyrights, test refactoring). 2019-12-21 07:53:11 +01:00
test-bug-176.sh Polishing sources (copyrights, test refactoring). 2019-12-21 07:53:11 +01:00
test-bug-228.sh Polishing sources (copyrights, test refactoring). 2019-12-21 07:53:11 +01:00
test-curses-keyb.sh Polishing sources (copyrights, test refactoring). 2019-12-21 07:53:11 +01:00
test-history-generator.sh Polishing sources (copyrights, test refactoring). 2019-12-21 07:53:11 +01:00
test-keyb.sh Polishing sources (copyrights, test refactoring). 2019-12-21 07:53:11 +01:00
test-utf8.sh Polishing sources (copyrights, test refactoring). 2019-12-21 07:53:11 +01:00