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.
This commit is contained in:
ZyX 2015-07-05 18:20:06 +03:00
parent c8c5da875c
commit 55712dcdb4

View File

@ -2525,6 +2525,14 @@ shada_read_next_item_start:
(uint64_t) initial_fpos); (uint64_t) initial_fpos);
goto shada_read_next_item_error; 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 = entry->data.history_item.histtype =
(uint8_t) unpacked.data.via.array.ptr[0].via.u64; (uint8_t) unpacked.data.via.array.ptr[0].via.u64;
const bool is_hist_search = const bool is_hist_search =