[FIXED] microService_AddEndpoint() could crash if subject is invalid - #831
Merged
Conversation
Saw that looking at the build log in GitHub actions:
```
/home/runner/work/nats.c/nats.c/src/micro.c: In function ‘micro_add_endpoint’:
/home/runner/work/nats.c/nats.c/src/micro.c:153:16: warning: pointer used after ‘free’ [-Wuse-after-free]
153 | return microError_Wrapf(micro_ErrorInvalidArg, "invalid subject '%s' for endpoint '%s'", fullSubject, cfg->Name);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/runner/work/nats.c/nats.c/src/microp.h:18,
from /home/runner/work/nats.c/nats.c/src/micro.c:16:
/home/runner/work/nats.c/nats.c/src/mem.h:28:29: note: call to ‘free’ here
28 | #define NATS_FREE(p) free((p))
| ^~~~~~~~~
/home/runner/work/nats.c/nats.c/src/micro.c:152:9: note: in expansion of macro ‘NATS_FREE’
152 | NATS_FREE(fullSubject);
| ^~~~~~~~~
```
Added an invalid subject endpoint config in one of the test to verify
the issue and the fix.
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #831 +/- ##
==========================================
+ Coverage 68.71% 70.49% +1.78%
==========================================
Files 39 47 +8
Lines 15207 15368 +161
Branches 3143 3149 +6
==========================================
+ Hits 10449 10834 +385
+ Misses 1700 1499 -201
+ Partials 3058 3035 -23 ☔ View full report in Codecov by Sentry. |
levb
reviewed
Jan 15, 2025
levb
approved these changes
Jan 15, 2025
github-actions Bot
pushed a commit
that referenced
this pull request
Jan 15, 2025
…uld crash if subject is invalid (#831)
levb
pushed a commit
that referenced
this pull request
Feb 28, 2025
…831) Saw that looking at the build log in GitHub actions: ``` /home/runner/work/nats.c/nats.c/src/micro.c: In function ‘micro_add_endpoint’: /home/runner/work/nats.c/nats.c/src/micro.c:153:16: warning: pointer used after ‘free’ [-Wuse-after-free] 153 | return microError_Wrapf(micro_ErrorInvalidArg, "invalid subject '%s' for endpoint '%s'", fullSubject, cfg->Name); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/runner/work/nats.c/nats.c/src/microp.h:18, from /home/runner/work/nats.c/nats.c/src/micro.c:16: /home/runner/work/nats.c/nats.c/src/mem.h:28:29: note: call to ‘free’ here 28 | #define NATS_FREE(p) free((p)) | ^~~~~~~~~ /home/runner/work/nats.c/nats.c/src/micro.c:152:9: note: in expansion of macro ‘NATS_FREE’ 152 | NATS_FREE(fullSubject); | ^~~~~~~~~ ``` Added an invalid subject endpoint config in one of the test to verify the issue and the fix. Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Saw that looking at the build log in GitHub actions:
Added an invalid subject endpoint config in one of the test to verify the issue and the fix.
Signed-off-by: Ivan Kozlovic ivan@synadia.com