fix(appsec): off by one#3506
Merged
realFlowControl merged 1 commit intomasterfrom Nov 28, 2025
Merged
Conversation
c5e87b1 to
3fa72d2
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3506 +/- ##
==========================================
- Coverage 61.83% 61.69% -0.14%
==========================================
Files 142 142
Lines 12923 12923
Branches 1695 1695
==========================================
- Hits 7991 7973 -18
- Misses 4178 4196 +18
Partials 754 754
... and 3 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Anilm3
approved these changes
Nov 28, 2025
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.
Description
sizeof("1")returns2because it includes the terminating\0, whilesprintf()always also writes the terminating\0. So if we do this (decrementing the return ofsizeof("string"):dd-trace-php/appsec/src/extension/request_abort.c
Lines 518 to 519 in 0c35caf
... then there is an off by one, as the
bufis "only" 20 bytes, whilesprintf()might actually write 21 bytes to that pointer if the number inbody_lenneeds 20 digits in a string. Additionally switching tosnprintf()makes sure we never overflow.Granted: this number overflowing seems highly unlikely, but theoretically still possible.
Reviewer checklist