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:
parent
7935b9d212
commit
c2564d34af
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user