Compare commits

...

No commits in common. "c8s" and "c9-beta" have entirely different histories.
c8s ... c9-beta

27 changed files with 20472 additions and 20848 deletions

View File

@ -1 +0,0 @@
1

1
.gitignore vendored
View File

@ -1,2 +1 @@
SOURCES/jq-1.6.tar.gz
/jq-1.6.tar.gz

1
.jq.metadata Normal file
View File

@ -0,0 +1 @@
02959bca30672e0dfe678e7b36464c8fb08ec389 SOURCES/jq-1.6.tar.gz

View File

@ -1,24 +0,0 @@
commit 2f09060afab23fe9390cce7cb860b10416e1bf5f
Author: itchyny <itchyny@cybozu.co.jp>
Date: Mon Apr 13 11:04:52 2026 +0900
Fix out-of-bounds read in jv_parse_sized()
This fixes CVE-2026-39979.
Co-authored-by: Mattias Wadman <mattias.wadman@gmail.com>
diff -up jq-1.6/src/jv_parse.c.orig jq-1.6/src/jv_parse.c
--- jq-1.6/src/jv_parse.c.orig 2026-04-23 10:22:41.774842081 +0200
+++ jq-1.6/src/jv_parse.c 2026-04-23 10:28:15.741885969 +0200
@@ -863,8 +863,9 @@ jv jv_parse_sized(const char* string, in
if (!jv_is_valid(value) && jv_invalid_has_msg(jv_copy(value))) {
jv msg = jv_invalid_get_msg(value);
- value = jv_invalid_with_msg(jv_string_fmt("%s (while parsing '%s')",
+ value = jv_invalid_with_msg(jv_string_fmt("%s (while parsing '%.*s')",
jv_string_value(msg),
+ length,
string));
jv_free(msg);
}

View File

@ -1,83 +0,0 @@
based on commit 0c7d133c3c7e37c00b6d46b658a02244fdd3c784
Author: itchyny <itchyny@cybozu.co.jp>
Date: Mon Apr 13 08:53:26 2026 +0900
Randomize hash seed to mitigate hash collision DoS attacks
The hash function used a fixed seed, allowing attackers to craft colliding keys
and cause O(n^2) object parsing performance. Initialize the seed from a random
source at process startup to prevent the attack. This fixes CVE-2026-40164.
Co-authored-by: Asaf Meizner <asafmeizner@gmail.com>
diff -up jq-1.6/configure.ac.orig jq-1.6/configure.ac
--- jq-1.6/configure.ac.orig 2026-04-23 13:11:08.425063387 +0200
+++ jq-1.6/configure.ac 2026-04-23 13:43:25.807324877 +0200
@@ -140,6 +140,9 @@ AC_CHECK_MEMBER([struct tm.tm_gmtoff], [
AC_CHECK_MEMBER([struct tm.__tm_gmtoff], [AC_DEFINE([HAVE_TM___TM_GMT_OFF],1,[Define to 1 if the system has the __tm_gmt_off field in struct tm])],
[], [[#include <time.h>]])
+AC_FIND_FUNC([arc4random], [c], [#include <stdlib.h>], [])
+AC_FIND_FUNC([getentropy], [c], [#include <unistd.h>], [0, 0])
+
AC_FIND_FUNC([pthread_key_create], [pthread], [#include <pthread.h>], [NULL, NULL])
AC_FIND_FUNC([pthread_once], [pthread], [#include <pthread.h>], [NULL, NULL])
AC_FIND_FUNC([atexit], [pthread], [#include <stdlib.h>], [NULL])
diff -up jq-1.6/src/jv.c.orig jq-1.6/src/jv.c
--- jq-1.6/src/jv.c.orig 2026-04-23 13:11:08.501988205 +0200
+++ jq-1.6/src/jv.c 2026-04-23 13:35:04.250952609 +0200
@@ -7,6 +7,10 @@
#include <stdarg.h>
#include <limits.h>
#include <math.h>
+#include <time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <pthread.h>
#include "jv_alloc.h"
#include "jv.h"
@@ -877,7 +881,33 @@ static jv jvp_string_append(jv string, c
}
}
-static const uint32_t HASH_SEED = 0x432A9843;
+static uint32_t hash_seed;
+static pthread_once_t hash_seed_once = PTHREAD_ONCE_INIT;
+
+static void jvp_hash_seed_init(void) {
+ uint32_t seed;
+#if defined(HAVE_ARC4RANDOM)
+ seed = arc4random();
+#elif defined(HAVE_GETENTROPY)
+ if (getentropy(&seed, sizeof(seed)) != 0)
+ seed = (uint32_t)getpid() ^ (uint32_t)time(NULL);
+#else
+ int fd = open("/dev/urandom", O_RDONLY);
+ if (fd >= 0) {
+ if (read(fd, &seed, sizeof(seed)) != 4)
+ seed = (uint32_t)getpid() ^ (uint32_t)time(NULL);
+ close(fd);
+ } else {
+ seed = (uint32_t)getpid() ^ (uint32_t)time(NULL);
+ }
+#endif
+ hash_seed = seed;
+}
+
+static uint32_t jvp_hash_seed(void) {
+ pthread_once(&hash_seed_once, jvp_hash_seed_init);
+ return hash_seed;
+}
static uint32_t rotl32 (uint32_t x, int8_t r){
return (x << r) | (x >> (32 - r));
@@ -896,7 +926,7 @@ static uint32_t jvp_string_hash(jv jstr)
int len = (int)jvp_string_length(str);
const int nblocks = len / 4;
- uint32_t h1 = HASH_SEED;
+ uint32_t h1 = jvp_hash_seed();
const uint32_t c1 = 0xcc9e2d51;
const uint32_t c2 = 0x1b873593;

View File

@ -1,6 +1,6 @@
diff -up jq-1.6/src/jv_aux.c.orig jq-1.6/src/jv_aux.c
--- jq-1.6/src/jv_aux.c.orig 2025-06-30 18:14:49.211823479 +0200
+++ jq-1.6/src/jv_aux.c 2025-06-30 18:15:20.270512946 +0200
--- jq-1.6/src/jv_aux.c.orig 2025-06-02 17:24:14.789647070 +0200
+++ jq-1.6/src/jv_aux.c 2025-06-02 17:29:13.339864069 +0200
@@ -162,18 +162,19 @@ jv jv_set(jv t, jv k, jv v) {
if (slice_len < insert_len) {
// array is growing
@ -26,43 +26,8 @@ diff -up jq-1.6/src/jv_aux.c.orig jq-1.6/src/jv_aux.c
}
jv_free(v);
diff -up jq-1.6/src/jv.c.orig jq-1.6/src/jv.c
--- jq-1.6/src/jv.c.orig 2025-06-30 18:14:49.221499541 +0200
+++ jq-1.6/src/jv.c 2025-06-30 18:17:11.071456789 +0200
@@ -326,10 +326,10 @@ static double jvp_literal_number_to_doub
decNumber *p_dec_number = jvp_dec_number_ptr(j);
decNumberDoublePrecision dec_double;
- char literal[BIN64_DEC_PRECISION + DEC_NUMBER_STRING_GUARD + 1];
+ char literal[BIN64_DEC_PRECISION + DEC_NUMBER_STRING_GUARD + 1];
// reduce the number to the shortest possible form
- // while also making sure than no more than BIN64_DEC_PRECISION
+ // while also making sure than no more than BIN64_DEC_PRECISION
// digits are used (dec_context_to_double)
decNumberReduce(&dec_double.number, p_dec_number, DEC_CONTEXT_TO_DOUBLE());
@@ -368,7 +368,7 @@ static const char* jvp_literal_number_li
// Preserve the actual precision as we have parsed it
// don't do decNumberTrim(pdec);
-
+
decNumberToString(pdec, plit->literal_data);
}
@@ -459,9 +459,9 @@ int jvp_number_cmp(jv a, jv b) {
assert(JVP_HAS_KIND(b, JV_KIND_NUMBER));
if(JVP_HAS_FLAGS(a, JVP_FLAGS_NUMBER_LITERAL) && JVP_HAS_FLAGS(b, JVP_FLAGS_NUMBER_LITERAL)) {
- decNumberSingle res;
- decNumberCompare(&res.number,
- jvp_dec_number_ptr(a),
+ decNumberSingle res;
+ decNumberCompare(&res.number,
+ jvp_dec_number_ptr(a),
jvp_dec_number_ptr(b),
DEC_CONTEXT()
);
--- jq-1.6/src/jv.c.orig 2025-06-02 17:24:14.800158498 +0200
+++ jq-1.6/src/jv.c 2025-06-02 17:33:17.395419062 +0200
@@ -703,6 +703,11 @@ jv jv_array_set(jv j, int idx, jv val) {
jv_free(val);
return jv_invalid_with_msg(jv_string("Out of bounds negative array index"));
@ -213,18 +178,9 @@ diff -up jq-1.6/src/jv.c.orig jq-1.6/src/jv.c
}
jv_free(b);
return a;
@@ -1671,7 +1698,7 @@ int jv_contains(jv a, jv b) {
r = jvp_array_contains(a, b);
} else if (JVP_HAS_KIND(a, JV_KIND_STRING)) {
int b_len = jv_string_length_bytes(jv_copy(b));
- if (b_len != 0) {
+ if (b_len != 0) {
r = _jq_memmem(jv_string_value(a), jv_string_length_bytes(jv_copy(a)),
jv_string_value(b), b_len) != 0;
} else {
diff -up jq-1.6/tests/jq.test.orig jq-1.6/tests/jq.test
--- jq-1.6/tests/jq.test.orig 2025-06-30 18:14:49.214961567 +0200
+++ jq-1.6/tests/jq.test 2025-06-30 18:15:20.271792714 +0200
--- jq-1.6/tests/jq.test.orig 2025-06-02 17:24:14.792756100 +0200
+++ jq-1.6/tests/jq.test 2025-06-02 17:29:13.339960811 +0200
@@ -186,6 +186,10 @@ null
[0,1,2]
[0,5,2]

View File

@ -1,6 +1,32 @@
Patch based on:
commit dc849e9bb74a7a164a3ea52f661cc712b1ffbd43
Author: itchyny <itchyny@cybozu.co.jp>
Date: Tue Mar 4 22:13:55 2025 +0900
Improve performance of repeating strings (#3272)
This commit improves the performance of repeating strings, by copying
the result string instead of the string being repeated. Also it adds
an error message when the result string is too long.
and
commit c6e041699d8cd31b97375a2596217aff2cfca85b
Author: itchyny <itchyny@cybozu.co.jp>
Date: Sat May 31 11:46:40 2025 +0900
Fix heap buffer overflow when formatting an empty string
The `jv_string_empty` did not properly null-terminate the string data,
which could lead to a heap buffer overflow. The test case of
GHSA-p7rr-28xf-3m5w (`0[""*0]`) was fixed by the commit dc849e9bb74a,
but another case (`0[[]|implode]`) was still vulnerable. This commit
ensures string data is properly null-terminated, and fixes CVE-2025-48060.
diff -up jq-1.6/src/builtin.c.orig jq-1.6/src/builtin.c
--- jq-1.6/src/builtin.c.orig 2025-06-30 19:07:06.250825334 +0200
+++ jq-1.6/src/builtin.c 2025-06-30 19:08:51.635668449 +0200
--- jq-1.6/src/builtin.c.orig 2025-06-18 16:41:04.634258088 +0200
+++ jq-1.6/src/builtin.c 2025-06-18 17:07:00.384104796 +0200
@@ -317,19 +317,10 @@ static jv f_multiply(jq_state *jq, jv in
str = b;
num = a;
@ -25,8 +51,8 @@ diff -up jq-1.6/src/builtin.c.orig jq-1.6/src/builtin.c
return jv_object_merge_recursive(a, b);
} else {
diff -up jq-1.6/src/jv.c.orig jq-1.6/src/jv.c
--- jq-1.6/src/jv.c.orig 2025-06-30 19:06:08.660648842 +0200
+++ jq-1.6/src/jv.c 2025-06-30 19:07:06.251424952 +0200
--- jq-1.6/src/jv.c.orig 2025-06-19 12:37:15.745792964 +0200
+++ jq-1.6/src/jv.c 2025-06-19 12:18:05.812121053 +0200
@@ -828,6 +828,7 @@ static jv jvp_string_empty_new(uint32_t
jvp_string* s = jvp_string_alloc(length);
s->length_hashed = 0;
@ -69,8 +95,8 @@ diff -up jq-1.6/src/jv.c.orig jq-1.6/src/jv.c
assert(JVP_HAS_KIND(j, JV_KIND_STRING));
assert(JVP_HAS_KIND(sep, JV_KIND_STRING));
diff -up jq-1.6/src/jv.h.orig jq-1.6/src/jv.h
--- jq-1.6/src/jv.h.orig 2025-06-30 19:06:08.614632776 +0200
+++ jq-1.6/src/jv.h 2025-06-30 19:07:06.251840524 +0200
--- jq-1.6/src/jv.h.orig 2025-06-18 16:36:33.079921073 +0200
+++ jq-1.6/src/jv.h 2025-06-18 16:41:04.635205790 +0200
@@ -120,6 +120,7 @@ jv jv_string_fmt(const char*, ...) JV_PR
jv jv_string_append_codepoint(jv a, uint32_t c);
jv jv_string_append_buf(jv a, const char* buf, int len);
@ -80,8 +106,8 @@ diff -up jq-1.6/src/jv.h.orig jq-1.6/src/jv.h
jv jv_string_explode(jv j);
jv jv_string_implode(jv j);
diff -up jq-1.6/tests/jq.test.orig jq-1.6/tests/jq.test
--- jq-1.6/tests/jq.test.orig 2025-06-30 19:06:08.661007480 +0200
+++ jq-1.6/tests/jq.test 2025-06-30 19:09:33.221816670 +0200
--- jq-1.6/tests/jq.test.orig 2025-06-19 12:34:53.179089126 +0200
+++ jq-1.6/tests/jq.test 2025-06-19 12:20:34.666161956 +0200
@@ -1169,6 +1169,18 @@ indices(", ")
["a", "ab", "abc"]
["aaa", "ababab", "abcabcabc"]

View File

@ -1,12 +1,13 @@
Name: jq
Version: 1.6
Release: 12%{?dist}
Release: 19%{?dist}
Summary: Command-line JSON processor
License: MIT and ASL 2.0 and CC-BY and GPLv3
URL: http://stedolan.github.io/jq/
Source0: https://github.com/stedolan/jq/releases/download/%{name}-%{version}/%{name}-%{version}.tar.gz
Patch0: 0000-jq-decimal-literal-number.patch
# Backport of PR#1752 for RHBZ#2008979
Patch0: jq-decimal-literal-number.patch
Patch1: 0001-iterration-problem-for-non-decimal-string.patch
Patch2: 0002-add-mantest.patch
Patch3: 0003-fix-pthread-segfault.patch
@ -14,37 +15,37 @@ Patch4: 0004-make-jq-fast.patch
Patch5: 0005-sast.patch
Patch6: 0006-CVE-2024-23337.patch
Patch7: 0007-CVE-2025-48060.patch
Patch8: 0008-CVE-2026-39979.patch
Patch9: 0009-CVE-2026-40164.patch
BuildRequires: gcc
BuildRequires: flex
BuildRequires: bison
BuildRequires: oniguruma-devel
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libtool
BuildRequires: chrpath
%ifnarch s390x
%ifarch %{valgrind_arches}
BuildRequires: valgrind
%endif
BuildRequires: make
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libtool
%description
lightweight and flexible command-line JSON processor
jq is like sed for JSON data you can use it to slice
and filter and map and transform structured data with
the same ease that sed, awk, grep and friends let you
play with text.
jq is like sed for JSON data you can use it to slice
and filter and map and transform structured data with
the same ease that sed, awk, grep and friends let you
play with text.
It is written in portable C, and it has zero runtime
dependencies.
It is written in portable C, and it has zero runtime
dependencies.
jq can mangle the data format that you have into the
one that you want with very little effort, and the
program to do so is often shorter and simpler than
you'd expect.
jq can mangle the data format that you have into the
one that you want with very little effort, and the
program to do so is often shorter and simpler than
you'd expect.
%package devel
Summary: Development files for %{name}
@ -58,7 +59,7 @@ Development files for %{name}
%autosetup -n %{name}-%{version} -p1
%build
autoreconf -fi
autoreconf -if
%configure --disable-static
make %{?_smp_mflags}
# Docs already shipped in jq's tarball.
@ -104,59 +105,72 @@ make check
%changelog
* Mon May 11 2026 Tomas Halman <thalman@redhat.com> - 1.6-12
- Fix CVE-2026-40164 - Denial of Service via crafted JSON object causing hash collisions
- Fix CVE-2026-39979 out-of-bounds read in jv_parse_sized()
- Resolves: RHEL-168174
- Resolves: RHEL-168192
* Thu Jun 19 2025 Tomas Halman <thalman@redhat.com> - 1.6-19
- Fix CVE-2025-48060
- Resolves: RHEL-92993
* Mon Jun 30 2025 Tomas Halman <thalman@redhat.com> - 1.6-11
- Fix CVE-2025-48060 AddressSanitizer: stack-buffer-overflow in jq_fuzz_execute (jv_string_vfmt)
- Resolves: RHEL-92987
* Tue Jun 3 2025 Tomas Halman <thalman@redhat.com> - 1.6-18
- Fix CVE-2024-23337
- Resolves: RHEL-92975
* Mon Jun 30 2025 Tomas Halman <thalman@redhat.com> - 1.6-10
- Fix CVE-2024-23337 jq has signed integer overflow in jv.c:jvp_array_write
- Resolves: RHEL-92968
* Fri May 3 2024 Tomas Halman <thalman@redhat.com> - 1.6-9
* Fri May 3 2024 Tomas Halman <thalman@redhat.com> - 1.6-17
- Fix SAST findings in jq 1.6
- Resolves: RHEL-37827
- Resolves: RHEL-28653
* Fri Oct 13 2023 Tomas Halman <thalman@redhat.com> - 1.6-8
* Fri Oct 13 2023 Tomas Halman <thalman@redhat.com> - 1.6-16
- Make jq 1.6 fast
- Resolves: RHEL-5052
- Resolves: RHEL-13431
* Tue Mar 14 2023 Tomas Halman <thalman@redhat.com> - 1.6-7
- Fix jq segfault when used in threads
- Resolves: rhbz#2092160
* Thu Mar 9 2023 Tomas Halman <thalman@redhat.com> - 1.6-15
- jq segfault when used in threads
- Resolves: rhbz#2176542
* Fri Nov 4 2022 Tomas Halman <thalman@redhat.com> - 1.6-6
- Add mantest to the gating
- Related: rhbz#2049601
- Related: rhbz#2049594
* Tue Oct 11 2022 Tomas Halman <thalman@redhat.com> - 1.6-5
- Remove rpath from jq binary
- Related: rhbz#2049601
* Fri Oct 21 2022 Tomas Halman <thalman@redhat.com> - 1.6-13
- jq try/catch stops iteration over items
Resolves: rhbz#2049594
* Tue Oct 11 2022 Tomas Halman <thalman@redhat.com> - 1.6-4
- Fix iterration problem for non decimal string
- Resolves: rhbz#2049601
* Mon Nov 15 2021 Tomas Halman <thalman@redhat.com>
- Strip rpath from jq binary
Related: rhbz#2008983
* Mon Oct 4 2021 Tomas Halman <thalman@redhat.com>
- Fix big integers issue
- Resolves: bug#2008717
* Wed Sep 29 2021 Davide Cavalca <dcavalca@centosproject.org> - 1.6-10
- Backport PR#1752 to fix an integer logic issue
Resolves: rhbz#2008983
* Mon Oct 4 2021 Tomas Halman <thalman@redhat.com>
- Releasing v1.6
- Resolves: bug#1852514
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 1.6-9
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Wed Aug 11 2021 Tomas Halman <thalman@redhat.com>
- Publishing devel package
- Resolves: bug#1908928
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 1.6-8
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Sat Aug 11 2018 Troy Dawson <tdawson@redhat.com>
- Fix typo: s390 -> s390x
- Related: bug#1614611
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.6-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Sat Dec 05 2020 Richard W.M. Jones <rjones@redhat.com> - 1.6-6
- Use correct valgrind_arches macro to check for valgrind.
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.6-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.6-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.6-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.6-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Thu Nov 08 2018 David Fetter <david@fetter.org> - 1.6-1
- Upstream 1.6.0
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.5-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Sun Apr 01 2018 Mamoru TASAKA <mtasaka@fedoraproject.org> - 1.5-12
- Rebuild against oniguruma 6.8.1

View File

@ -1,6 +0,0 @@
--- !Policy
product_versions:
- rhel-8
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

View File

@ -1,23 +0,0 @@
summary: Run gating tests
discover:
how: fmf
dist-git-source: true
dist-git-type: centos
prepare:
- how: install
package:
- dnf-plugins-core
- https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
- how: shell
script: /usr/bin/crb enable
- how: install
package:
- jq
- jq-devel
- gcc
- wget
- how: shell
script: dnf config-manager --disable epel*
execute:
how: tmt

View File

@ -1 +0,0 @@
SHA512 (jq-1.6.tar.gz) = f5ae8be558ca2ff15324c378d623106b74bd0823be50835e23548584aa1eb24eb81f8f054693d5d3fe44f157d0735c5f0f40b9f21899ba068f2a11d1345ace19

View File

@ -1,20 +0,0 @@
#!/bin/bash
export LC_ALL=C
stress_jq() {
`which time` -p -f '%e\n' bash -c 'for i in `seq 1 1000` ; do echo '"'"'{"foo":"bar"}'"'"' | jq '"'"'has("bar")'"'"' > /dev/null ; done' 2>&1 | cut -d. -f1
}
FAIL=0
TIME=`stress_jq`
echo -n "Test jqspeed ... "
if [ $TIME -gt 8 ] ; then
echo "failed"
FAIL=1
else
echo "ok"
fi
echo "Runtime: ${TIME}s "
exit $FAIL

View File

@ -1,6 +0,0 @@
summary: Run jq performance/speed test
require:
- jq
- which
- time
test: ./jqspeed.sh

View File

View File

@ -1,5 +0,0 @@
---
standard-inventory-qcow2:
qemu:
m: 2G

View File

@ -1,19 +0,0 @@
#!/bin/sh
FAIL=0
# Test for segfault in multithreaded environment
gcc -o test_segfault test_segfault_with_multithreaded_env.c -lpthread -ljq && \
./test_segfault
RET=$?
echo -n "Test jqsegfault ... "
if [ $RET != 0 ]; then
echo "failed"
FAIL=1
else
echo "ok"
fi
exit $FAIL

View File

@ -1,8 +0,0 @@
summary: Run segfault threads test
require:
- wget
- dnf-utils
- gcc
- jq
- jq-devel
test: ./jqsegfault.sh

View File

@ -1,90 +0,0 @@
#include <stdlib.h>
#include <jq.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
int my_jq_parse(jq_state *jq, struct jv_parser *parser)
{
int rv = 0;
jv value;
value = jv_parser_next(parser);
while (jv_is_valid(value)) {
jq_start(jq, value, 0);
jv result;
while (jv_is_valid(result = jq_next(jq))) {
jv dumped = jv_dump_string(result, 0);
const char *str = jv_string_value(dumped);
printf("dumped: %s\n", str);
}
jv_free(result);
value = jv_parser_next(parser);
}
if (jv_invalid_has_msg(jv_copy(value))) {
jv msg = jv_invalid_get_msg(value);
printf("invalid: %s\n", jv_string_value(msg));
jv_free(msg);
rv = 1;
} else {
jv_free(value);
}
return rv;
}
void *run(void *not_used) {
int rv;
jq_state *jq;
const char *prg = ".data";
jq = jq_init();
printf("jq_init jq: %p prg: %s\n", jq, prg);
if (jq_compile(jq, prg) == 0) {
jq_teardown(&jq);
return NULL;
}
printf("compiled\n");
struct jv_parser *parser = jv_parser_new(0);
const char *buf = "{ \"data\": 1 }";
jv_parser_set_buf(parser, buf, strlen(buf), 0);
rv = my_jq_parse(jq, parser);
if (rv != 0) {
printf("my_jq_parse failed!\n");
}
jv_parser_free(parser);
jq_teardown(&jq);
return NULL;
}
#define THREADS 2
/* calling run() twice works fine */
/* calling them in threads causes core-dump */
int main (int argc, char *argv[])
{
pthread_t threads[THREADS];
int createerror;
int a;
memset(&threads, 0, sizeof(threads));
for (a = 0; a < THREADS; ++a) {
// sleep(1); // < if you want to run threads sequentionally
createerror = pthread_create(&threads[a], NULL, run, NULL);
if (createerror) {
printf("create thread error %d\n", a);
}
}
for(a = 0; a < THREADS; ++a) {
if (threads[a] != 0) {
pthread_join(threads[a], NULL);
}
}
return 0;
}

View File

@ -1,27 +0,0 @@
---
- hosts: localhost
roles:
- role: standard-test-source
tags:
- always
- role: standard-test-basic
tags:
- classic
required_packages:
- jq
- gcc
- wget
- jq-devel
- valgrind
- rubygem-rake
tests:
- upstream:
dir: upstream
run: ./jqtests.sh
- segfault:
dir: segfault
run: ./jqsegfault.sh
- performance:
dir: performance
run: ./jqspeed.sh

View File

@ -1,48 +0,0 @@
#!/bin/sh
die () {
echo "$1" >&2
exit 1
}
# If source not found, download it with dnf
if [ ! -d ./source ]; then
# Extract source from srpm
dnf download --source jq && \
rpm2cpio jq*.rpm|cpio -id && \
mkdir source && \
tar -zxf jq-*.tar.gz -C source --strip-components=1
if [ $? != 0 ]; then
echo "Failed to download upstream tests"
exit 1
fi
fi
pushd ./source || die "missing source directory"
rm -f jq tests/*.log 2>/dev/null
ln -s /usr/bin/jq || die "failed to link jq binary"
FAIL=0
# run the tests
# List of tests is taken from Makefile
TESTS="tests/optionaltest tests/mantest tests/jqtest tests/onigtest tests/shtest tests/utf8test tests/base64test"
for t in $TESTS; do
echo -n "Test $t ... "
./${t} >"${t}.log" 2>&1
RET=$?
if [ $RET = 0 ]; then
echo "ok"
else
echo "failed"
echo "-------------------- ${t}.log start -----------------------------"
cat "${t}.log"
echo "-------------------- ${t}.log end -----------------------------"
FAIL=1
fi
done
popd # exit SOURCE_DIR
exit $FAIL

View File

@ -1,11 +0,0 @@
summary: Run jq gating tests
require:
- wget
- dnf-utils
- gcc
- jq
- jq-devel
- valgrind
- diffutils
test: ./jqtests.sh
duration: 30m