Commit graph

848 commits

Author SHA1 Message Date
Björn Svensson 9887545ab0 Install headers in correct path when using CMake
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.
2023-11-03 09:49:16 +01:00
Björn Svensson c105117b40
Use PCRE2 instead of PCRE (#153)
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.
2023-10-23 12:38:24 +02:00
Björn Svensson 9168f7e4d4 Support C23 projects
Don't define true/false/bool when r3 is used by C23 projects
since C23 already has a bool type and predefined constants.
2023-10-23 10:45:18 +02:00
Björn Svensson 58d8b0c028 Use coverity-scan-action in CI
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.
2023-10-23 10:35:38 +02:00
Yo-An Lin 91405adda5
Merge pull request #152 from c9s/c9s-patch-1 2023-02-12 10:52:51 +08:00
Yo-An Lin b6639e557f
Update coverity.yml 2022-08-24 16:05:06 +08:00
Yo-An Lin c8123430a9
remove coverity env var since it is not working 2022-07-21 00:41:08 +08:00
Bjorn Svensson 9b69f38527
Fix leak in r3_tree_insert_pathl_ex() (#150)
Includes a testcase triggering the issue when building with
the leak sanitizer.

Resource leak (CID 355063) found by Coverity,
2022-07-20 13:23:45 +02:00
Yo-An Lin 25cc816025
Fix coverity token variable (#151) 2022-07-20 13:08:42 +02:00
Yo-An Lin edbeb0631d
Merge pull request #149 from Nordix/coverity-in-ci
Add Coverity Scan to CI
2022-07-19 17:20:04 +08:00
Björn Svensson 04d52a6dd1 Fix Coverity warning
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.
2021-11-10 22:20:46 +01:00
Björn Svensson cfed420cd3 Add Coverity Scan to CI 2021-11-10 22:20:34 +01:00
Yo-An Lin 76e2770304
Merge pull request #148 from Nordix/faulty-slug-in-insert-route
Handle incomplete slug pattern when inserting a route
2021-11-05 09:27:52 +08:00
Yo-An Lin 90450def8b
Merge pull request #147 from Nordix/memory-pool-cleanups
Remove unused memory pool and memory code
2021-11-05 09:26:46 +08:00
Björn Svensson 2f3e0b01ff Handle incomplete slug in insert route 2021-11-04 20:22:10 +01:00
Björn Svensson bf11f8e2e6 Remove unused code in memory.c/.h 2021-11-03 21:58:33 +01:00
Björn Svensson f0dd25bd53 Remove unused memory pool 2021-11-03 21:22:48 +01:00
Yo-An Lin e533bae646
Merge pull request #146 from Nordix/coveralls-action
Use recommended Coveralls GitHub action in CI
2021-10-28 21:14:43 +08:00
Björn Svensson b44f052897 Use recommended Coveralls GitHub action in CI 2021-10-19 11:18:53 +02:00
Yo-An Lin 06c4fc41bf
Merge pull request #140 from Nordix/test-leak-fixes
Correcting leaks in tests
2021-10-19 02:45:18 +08:00
Yo-An Lin 35c5d13df8
Merge pull request #144 from Nordix/migrate-ci-to-github-actions
Add CI via Github Actions
2021-10-19 02:44:40 +08:00
Yo-An Lin 4f3c1cd994
Merge pull request #145 from Nordix/misaligned-address-error
Remove fixed alignment
2021-10-19 02:44:14 +08:00
Björn Svensson 5114d894e5 Remove fixed alignment 2021-10-18 11:36:54 +02:00
Björn Svensson 79a3bc7c50 Add CI via Github Actions
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.
2021-10-18 09:08:42 +02:00
Björn Svensson 9c8feff07f Correcting leaks in tests
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 ..`
2021-10-14 08:27:19 +02:00
Yo-An Lin b13dc8aa6e
Merge pull request #131 from iresty/feature-ipv6
feature: supported to use ipv6 address match route.
2021-10-14 10:31:23 +08:00
Yo-An Lin eca8d9992e
Merge pull request #143 from Nordix/str_array-fixes
Corrections in `str_array`
2021-10-14 10:29:49 +08:00
Yo-An Lin c9743f3904
Merge pull request #142 from Nordix/invalid-read-corrections
Correcting buffer over-read errors
2021-10-14 10:29:19 +08:00
Björn Svensson 383717a8c7 Update the faulty access macros for str_array
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.
2021-10-13 08:47:20 +02:00
Björn Svensson 673bb2f6d9 Remove declarations for nonexisting functions in str_array.h 2021-10-13 08:47:20 +02:00
Björn Svensson 4babe735e8 Remove cyclic dependency between str_array.h and r3.h
This also makes sure we dont get warnings regarding bool
redefinitions when building with clang.
2021-10-13 08:46:47 +02:00
Björn Svensson 0072b618b6 Check for existence of stdbool.h during CMake builds
The headerfile is searched for during autogen/autoconf builds to
determine when to include stdbool.h.
This let CMake builds have the same behavior.
2021-10-12 10:52:44 +02:00
Björn Svensson 00ec8b7f2b Correct buffer over-read errors
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`
2021-10-11 10:19:09 +02:00
Yo-An Lin d2fcf2f2d4
Merge pull request #135 from fishgege/patch-1
bugfix: insert path success, but get data failed
2021-10-07 22:08:13 +08:00
Yo-An Lin da0c89b6db
Merge pull request #137 from dthadi3/ppc64le
Travis-ci: added support for ppc64le
2021-10-07 22:07:24 +08:00
Yo-An Lin 3228fb8cb5
Merge pull request #141 from Nordix/multi-edge-corrections
Correcting issue and memory leak when using multiple edges
2021-10-07 22:07:02 +08:00
Björn Svensson ff1ef2c148 Correcting issue with multiple edges
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.
2021-09-20 16:55:37 +02:00
Devendranath Thadi ac7af9697c Travis-ci: added support for ppc64le 2020-11-18 14:14:29 +00:00
董宇 36198aefba
bugfix: insert path success, but get data failed
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
2019-12-15 13:05:49 +08:00
Yo-An Lin e20e48a5ce
Merge pull request #128 from iresty/bug-end-maybe-0-len
bugfix: the end matching length is 0.
2019-08-06 10:22:30 +08:00
Yuansheng 79fd587615 feature: supported to match ipv6 address. 2019-08-01 21:38:14 -04:00
Yuansheng 1b9e007dfc bugfix: make a try for endpoint. 2019-07-21 08:46:37 -04:00
Yuansheng 81f77ffe5a test: added test cases. 2019-07-21 08:46:37 -04:00
Yuansheng 0d70b8f5de bugfix: the end matching length is 0. 2019-07-21 08:46:37 -04:00
Yo-An Lin 577cfa0ccb
Merge pull request #130 from iresty/typo
change: typo.
2019-07-21 19:30:50 +08:00
Yo-An Lin 3dac164cec
Merge pull request #126 from iresty/optimize-wildcard
optimize: optimized pattern `.*`, which can be used prefix matching.
2019-07-21 19:30:37 +08:00
Yuansheng f8a3741211 change: typo. 2019-07-21 09:14:37 +08:00
Yuansheng 845c47907f test: describe the test case name. 2019-07-21 07:48:11 +08:00
Yuansheng 2ad6b4c4f0 test: skip one test case, will fix it later. 2019-07-20 22:58:17 +08:00
Yuansheng 3364df80ee test: run test case check_routes2. 2019-07-20 22:55:44 +08:00