From 55712dcdb43cf8ace896e955d41c22156cd79cc4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 5 Jul 2015 18:20:06 +0300 Subject: 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. --- src/nvim/shada.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') 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 = -- cgit