Skip to content
Myr

Add runtime type checks to f_string_indexes

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This fixes CVE-2026-39956.

authored by tlsbollei · committed by itchyny · parent e47e56d · Browse files · 2 files+17 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+17 added−0 removed

  • tests:+9 added−0 removed
  • other:+8 added−0 removed

2 files+17 added−0 removed

modified:src/builtin.c+8 added
1304 unmodified lines
1305 return jv_string_explode(a);1306}13071308static jv f_string_indexes(jq_state *jq, jv a, jv b) {1309 if (jv_get_kind(a) != JV_KIND_STRING) {1310 jv_free(b);1311 return type_error(a, "cannot be searched, as it is not a string");1312 }1313 if (jv_get_kind(b) != JV_KIND_STRING) {1314 jv_free(a);1315 return type_error(b, "is not a string");1316 }1317 return jv_string_indexes(a, b);1318}13191320enum trim_op {
787 unmodified lines
modified:tests/jq.test+9 added
1547 unmodified lines
1548[ index("aba"), rindex("aba"), indices("aba") ]1549"xababababax"1550[1,7,[1,3,5,7]]15511552# _strindices is used by indices/1 but is callable1553try _strindices("abc") catch .15541231555"number (123) cannot be searched, as it is not a string"15561557try _strindices(123) catch .1558"abc"1559"number (123) is not a string"15601561# trim1562# \u000b is vertical tab (\v not supported by json)1563map(trim), map(ltrim), map(rtrim)1564[" \n\t\r\f\u000b", ""," ", "a", " a ", "abc", " abc ", " abc", "abc "]
1006 unmodified lines