Skip to content

Fix Inverted Bit-Index and Shared Lock Leak on Event Lookup Failure#81

Merged
douzzer merged 5 commits intowolfSSL:masterfrom
aidangarske:fenrir-fixes-wolfsentry-1
Apr 16, 2026
Merged

Fix Inverted Bit-Index and Shared Lock Leak on Event Lookup Failure#81
douzzer merged 5 commits intowolfSSL:masterfrom
aidangarske:fenrir-fixes-wolfsentry-1

Conversation

@aidangarske
Copy link
Copy Markdown
Member

Description

F-2454, F-2062

…ndex in partial-byte subnet comparison and address masking
…ak when wolfsentry_event_get_reference fails in dispatch_by_route and dispatch_by_id
@aidangarske aidangarske self-assigned this Apr 8, 2026
Copilot AI review requested due to automatic review settings April 8, 2026 19:03

This comment was marked as resolved.

wolfSSL-Fenrir-bot

This comment was marked as resolved.

…init_by_exports (lines 903-904, 920-921) — swapped left_over_bits and (BITS_PER_BYTE - left_over_bits) in

  check/clear masks
  - HIGH-1 test: Added /25 subnet test via wolfsentry_route_insert_by_exports with a dirty low bit to validate masking through the exports path
  - MEDIUM-1: Added comment clarifying the route pointer remains valid after drop_reference because the table holds its own reference
@aidangarske aidangarske requested review from Copilot and removed request for Copilot April 9, 2026 17:33
@aidangarske aidangarske requested a review from douzzer April 9, 2026 18:27
@aidangarske aidangarske removed their assignment Apr 9, 2026
Copy link
Copy Markdown
Collaborator

@douzzer douzzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catches by Mr. Claude!

To get a clean run of make check-all, I needed the following tweaks:

diff --git a/tests/unittests.c b/tests/unittests.c
index 591068f..1817b60 100644
--- a/tests/unittests.c
+++ b/tests/unittests.c
@@ -2372,8 +2372,7 @@ static int test_static_routes(void) {
 
 #ifdef WOLFSENTRY_THREADSAFE
         /* if the shared lock leaked, this unlock would succeed. */
-        WOLFSENTRY_EXIT_ON_SUCCESS(
-            wolfsentry_context_unlock(WOLFSENTRY_CONTEXT_ARGS_OUT));
+        WOLFSENTRY_EXIT_ON_FALSE(wolfsentry->lock.state == WOLFSENTRY_LOCK_UNLOCKED);
 #endif
 
         /* likewise test that dispatch_by_id does not leak its shared lock
@@ -2391,8 +2390,7 @@ static int test_static_routes(void) {
 
 #ifdef WOLFSENTRY_THREADSAFE
         /* if the shared lock leaked, this unlock would succeed. */
-        WOLFSENTRY_EXIT_ON_SUCCESS(
-            wolfsentry_context_unlock(WOLFSENTRY_CONTEXT_ARGS_OUT));
+        WOLFSENTRY_EXIT_ON_FALSE(wolfsentry->lock.state == WOLFSENTRY_LOCK_UNLOCKED);
 #endif
 
         WOLFSENTRY_EXIT_ON_FAILURE(
@@ -2651,7 +2649,7 @@ static int test_static_routes(void) {
                         | WOLFSENTRY_ROUTE_FLAG_REMOTE_INTERFACE_WILDCARD;
 
         /* 192.168.1.0/25 -- intentionally set a low bit that must be masked */
-        memcpy(exp_remote_addr, "\xC0\xA8\x01\x01", 4);
+        memcpy(exp_remote_addr, "\xC0\xA8\x01\x01", 4); /* NOLINT(bugprone-not-null-terminated-result) */
         exp_route.remote_address = exp_remote_addr;
         exp_route.remote.addr_len = 25;
         exp_route.remote.sa_port = 0;

@aidangarske aidangarske requested review from Copilot and removed request for Copilot April 16, 2026 16:35
Copy link
Copy Markdown
Collaborator

@douzzer douzzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. passes local make check-all

@douzzer douzzer merged commit e515ae3 into wolfSSL:master Apr 16, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants