0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-20 10:08:43 +00:00

Tree/Trie: Check the end of buffer

We set buffer->pos to buffer->end in function buffer_print() when
bvsnprintf() failed, so there would be uninitialized memory between
the old buffer->pos and the current buffer->pos.
This commit is contained in:
Pavel Tvrdik 2016-10-01 12:50:29 +02:00 committed by Ondrej Zajicek (work)
parent 7935b9d212
commit c2564d34af
2 changed files with 6 additions and 0 deletions

View File

@ -165,6 +165,9 @@ tree_format(struct f_tree *t, buffer *buf)
tree_node_format(t, buf);
if (buf->pos == buf->end)
return;
/* Undo last separator */
if (buf->pos[-1] != '[')
buf->pos -= 2;

View File

@ -300,6 +300,9 @@ trie_format(struct f_trie *t, buffer *buf)
buffer_print(buf, "%I/%d, ", IPA_NONE, 0);
trie_node_format(t->root, buf);
if (buf->pos == buf->end)
return;
/* Undo last separator */
if (buf->pos[-1] != '[')
buf->pos -= 2;