pkg-config provides users with the include path `../include/r3`
while CMake installs the headers directly under `../include/`.
This corrects the installation path to match the generated r3.pc
and to get the same result as when using autoconf.
PCRE is now at end of life and is no longer actively maintained.
Lift the dependency to the next major version, i.e. PCRE2.
Implementation notes:
- Removed the pcre study option since:
"The new API ... was simplified by abolishing the separate "study" optimizing
function; in PCRE2, patterns are automatically optimized where possible."
- If asprintf() fails the content of the 'strp' variable is undefined.
Lets check the return value and return NULL upon error.
- Pattern and subject can straightforwardly be cast to PCRE2_SPTR since we
only work with 8-bit code units.
Simplifies the CI job and adds a cache to avoid downloading the 1GB+
tool archive on every run.
See: https://github.com/vapier/coverity-scan-action
Only run this job when a commit is pushed to the default branch 2.0
(like when a PR is merged) since the required Coverity token/secret
is not available when this job is triggered by forks.
The return value was checked on all calls to r3_slug_find_placeholder()
except in one place, which triggered a Coverity warning.
This adds a check (assert), and enables the other asserts for non-debug
builds to catch segmentation faults early.
This is an initial setup with similarities to how we test
via TravisCI; build via autotools and build via cmake.
Additional testmatrix for sanitizer testing.
A couple of testcases did not free its `match_entry` allocations,
which triggers leak indications.
Visible when build and run using the leak sanitizer, i.e
`CFLAGS="-fno-omit-frame-pointer -fsanitize=leak" cmake ..`
Adds a testcase for the usage of the access macros, and also
updates the testsuite to only include what str_array requires.
This shows that str_array can be used separately by users.
When inserting multiple routes with common slug patterns
there are reads beyond end of strings.
The scenario is added as a testcase and can be triggered by
the address-sanitizer when built using:
`CFLAGS="-fno-omit-frame-pointer -fsanitize=address" cmake ..`
Indicated as a `buffer-overflow`
When `r3_node_find_common_prefix()` searches for the common prefix it
selects the first matched edge, which might not be the best match.
This issue gives memoryleaks which can be viewed in legacy
testcase `check_tree::test_insert_pathl()` by building using:
`CFLAGS="-fno-omit-frame-pointer -fsanitize=leak" cmake ..`
See testcase procedures:
ret = r3_tree_insert_path(n, "/foo/{id}", NULL);
..
ret = r3_tree_insert_path(n, "/foo/{idx}/{idy}", NULL);
..
ret = r3_tree_insert_path(n, "/foo/{idx}/{idh}", NULL); <-- leaks
Also added a testcase that triggers the problem including a leak for
reproduction on baseline.
background : use r3_tree_insert_pathl_ex to add path,A : abcdefg B:abc
When the node A already exists, we set B, then will split the node and make a branch, suboath_len is 0
In this case, branch a zero len subpath, which tree's data not set