balabit/syslog-ng — pull request #152 by bazsi (2014-07-06 16:19:03+00:00)
Title: value-pairs: fix handling subsequent hierarchical elements

When two hierarchical elements are subsequent to each other, the first one
wasn't properly closed when iterated using value_pairs_walk()

The problem was that value_pairs_walker() didn't validate that the
existing stack contents match the name being rendered, causing the new
prefix not to be recognized.

For example, if the following two name-value pairs come after each other:
* .unix.cmd
* .json.foo

Then, when .json.foo is being processed, vp_walker_name_split() determines
that "foo" is the key, without checking that ".json" is in a different
prefix than the previous name-value pair, which in turn causes
the obj_start() call to be omitted.

The code is now restructured so that we unwind first to the proper prefix
(calling obj_end() as needed), this ensures that we already are at
the proper prefix, then do name_split() which calls obj_start() as needed,
and then process the value.

The change also removes the return value from vp_walker_stack_unwind_until()
as we always use the top of the stack anyway.

Signed-off-by: Balazs Scheidler