aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2015-07-05 18:20:06 +0300
committerZyX <kp-pav@yandex.ru>2015-10-08 22:00:05 +0300
commit55712dcdb43cf8ace896e955d41c22156cd79cc4 (patch)
treee0d08c7ac0c166c4499dad336e9f918f02fa9a19 /src
parentc8c5da875c0b7d37c4aedc6b2301441fdc004ac4 (diff)
downloadrneovim-55712dcdb43cf8ace896e955d41c22156cd79cc4.tar.gz
rneovim-55712dcdb43cf8ace896e955d41c22156cd79cc4.tar.bz2
rneovim-55712dcdb43cf8ace896e955d41c22156cd79cc4.zip
shada: Test that history string does not contain zero byte
This test can safely be ignored for other kinds of strings, but history string contains separator after the last NUL byte and string containing NUL byte inside thus means that separator will be placed at one position, but seeked at another.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/shada.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 053257e746..72933df9a4 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -2525,6 +2525,14 @@ shada_read_next_item_start:
(uint64_t) initial_fpos);
goto shada_read_next_item_error;
}
+ if (memchr(unpacked.data.via.array.ptr[1].via.bin.ptr, 0,
+ unpacked.data.via.array.ptr[1].via.bin.size) != NULL) {
+ emsgu("Error while reading ShaDa file: "
+ "history entry at position %" PRIu64 " "
+ "contains string with zero byte inside",
+ (uint64_t) initial_fpos);
+ goto shada_read_next_item_error;
+ }
entry->data.history_item.histtype =
(uint8_t) unpacked.data.via.array.ptr[0].via.u64;
const bool is_hist_search =