mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-08-20 04:05:05 +02: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);
|
tree_node_format(t, buf);
|
||||||
|
|
||||||
|
if (buf->pos == buf->end)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Undo last separator */
|
/* Undo last separator */
|
||||||
if (buf->pos[-1] != '[')
|
if (buf->pos[-1] != '[')
|
||||||
buf->pos -= 2;
|
buf->pos -= 2;
|
||||||
|
@ -300,6 +300,9 @@ trie_format(struct f_trie *t, buffer *buf)
|
|||||||
buffer_print(buf, "%I/%d, ", IPA_NONE, 0);
|
buffer_print(buf, "%I/%d, ", IPA_NONE, 0);
|
||||||
trie_node_format(t->root, buf);
|
trie_node_format(t->root, buf);
|
||||||
|
|
||||||
|
if (buf->pos == buf->end)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Undo last separator */
|
/* Undo last separator */
|
||||||
if (buf->pos[-1] != '[')
|
if (buf->pos[-1] != '[')
|
||||||
buf->pos -= 2;
|
buf->pos -= 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user