]> git.ipfire.org Git - thirdparty/systemd.git/commit
json: be more careful when iterating through a JSON object/array 12290/head
authorLennart Poettering <lennart@poettering.net>
Fri, 12 Apr 2019 10:59:05 +0000 (12:59 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 12 Apr 2019 11:11:11 +0000 (13:11 +0200)
commit1b266e3c6f462dd835d3890ab4b1cb316b6fc205
treee6618607f11d5694921b52b35fffcacaad06962f
parent33d60b8d57b0dc9e1a7b700ab5c9060d170247f7
json: be more careful when iterating through a JSON object/array

Let's exit the loop early in case the variant is not actually an object
or array. This is safer since otherwise we might end up iterating
through these variants and access fields that aren't of the type we
expect them to be and then bad things happen.

Of course, this doesn't absolve uses of these macros to check the type
of the variant explicitly beforehand, but it makes it less bad if they
forget to do so.
src/shared/json.h