diff options
author | Emanuele Torre <torreemanuele6@gmail.com> | 2023-08-27 00:30:35 +0200 |
---|---|---|
committer | Nico Williams <nico@cryptonector.com> | 2023-08-27 00:37:54 -0500 |
commit | ab47880b4c6a6cda55a4c6b93f7990baef990e1e (patch) | |
tree | 216b3383531d896ef7fd4903150ebbd838382352 | |
parent | 6436f1e0f8687a65471f5fec07e85f64adaa66e9 (diff) |
Make jq_get_lib_dirs return an empty array if JQ_LIBRARY_PATH is not set
For the jq_state used by the jq utility, the JQ_LIBRARY_PATH attribute
will always be set, but, in general, it is possible that it might not
be.
If it is not set, jq_get_lib_dirs() will return jv_invalid().
That is not good, because some code in linker.c expects it to always
returns an array.
This patch makes jq_get_lib_dirs() return an empty array if
JQ_LIBRARY_PATH is not set to prevent problems.
This issue made OSS fuzz trigger failed assertions every time it tried
to compile a script that uses "include".
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61796
-rw-r--r-- | src/execute.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/execute.c b/src/execute.c index 367819e8..02af8232 100644 --- a/src/execute.c +++ b/src/execute.c @@ -1267,7 +1267,8 @@ jv jq_get_prog_origin(jq_state *jq) { } jv jq_get_lib_dirs(jq_state *jq) { - return jq_get_attr(jq, jv_string("JQ_LIBRARY_PATH")); + jv lib_dirs = jq_get_attr(jq, jv_string("JQ_LIBRARY_PATH")); + return jv_is_valid(lib_dirs) ? lib_dirs : jv_array(); } void jq_set_attrs(jq_state *jq, jv attrs) { |