summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEmanuele Torre <torreemanuele6@gmail.com>2023-12-13 15:13:46 +0100
committerGitHub <noreply@github.com>2023-12-13 15:13:46 +0100
commit511d50b15b0a903639874e933d941bad50de6652 (patch)
tree80fdb5564fa4cfbf5ed61c0a9b8e14667d47efac /tests
parent7298972551d43b44dd33a079927e06f2d15151f8 (diff)
ltrimstr/1+rtrimstr/1: don't leak on invalid input or arguments
ltrimstr/rtrimstr was ignoring and leaking the error returned by f_startswith()/f_endswith(). This also means that they just let the input pass through for non-string inputs or arguments. Only fix the leak for now; in the next release, #2969 will make them rethrow the error returned by startswith/endswith. Ref: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64946
Diffstat (limited to 'tests')
-rw-r--r--tests/jq.test15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/jq.test b/tests/jq.test
index 945ea04f..4c8416dc 100644
--- a/tests/jq.test
+++ b/tests/jq.test
@@ -2091,7 +2091,22 @@ try ("foobar" | .[1.5]) catch .
null
"Cannot index string with number"
+
# setpath/2 does not leak the input after an invalid get #2970
+
try ["ok", setpath([1]; 1)] catch ["ko", .]
{"hi":"hello"}
["ko","Cannot index object with number"]
+
+
+# ltrimstr/1 rtrimstr/1 don't leak on invalid input #2977
+
+try ltrimstr(1) catch "x", try rtrimstr(1) catch "x" | "ok"
+"hi"
+"ok"
+"ok"
+
+try ltrimstr("x") catch "x", try rtrimstr("x") catch "x" | "ok"
+{"hey":[]}
+"ok"
+"ok"