-
Notifications
You must be signed in to change notification settings - Fork 53
fix: free two memory leaks found by the valgrind soak #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fzipi
wants to merge
3
commits into
owasp-modsecurity:master
Choose a base branch
from
fzipi:fix/memory-leaks
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
Repository: owasp-modsecurity/ModSecurity-apache
Length of output: 7808
🏁 Script executed:
Repository: owasp-modsecurity/ModSecurity-apache
Length of output: 4580
🌐 Web query:
Apache httpd ap_get_client_block source return negative error ap_setup_client_block input filter handler phase💡 Result:
In the Apache HTTP Server API, ap_get_client_block is a legacy function used to read the request body in a loop [1][2]. According to official documentation and source code, its return value is interpreted as follows: - A positive value represents the number of bytes successfully read and stored in the provided buffer [3][2]. - 0 indicates the end of the request body (EOF) [4][3]. - -1 indicates that an error occurred during the read operation [4][3][2]. When ap_get_client_block returns -1, it signifies a failure, such as a read timeout, a connection drop, or an improperly configured filter [5][6]. Internally, the function invokes the input filter chain via ap_get_brigade [6]. If the underlying filter returns an error status, ap_get_client_block propagates this as a generic -1 [6]. Because of this loss of specific error context, developers are often advised against using ap_get_client_block in modern Apache modules in favor of direct filter interaction [6]. Regarding the setup phase, ap_setup_client_block must be called near the beginning of the handler phase (or specifically before any body-reading logic) to initialize the request properties, such as handling Transfer-Encoding or Content-Length [4][1][7]. This function returns an integer status code: OK on success, or a specific HTTP error code (e.g., HTTP_BAD_REQUEST, HTTP_LENGTH_REQUIRED, or HTTP_NOT_IMPLEMENTED) if initialization fails [4][2]. Modules are expected to return this error code if ap_setup_client_block fails [4][1].
Citations:
Preserve the request body for the application handler.
hook_request_lateconsumes the body throughap_get_client_block()before returningDECLINED.input_filterforwards replacement buckets and deletes the originals without retaining them. A later CGI, proxy, or application handler can therefore receive an empty POST or PUT body.Buffer and replay the body, or inspect it at the consumer read boundary. If
ap_get_client_block()returns a negative length, return an error instead of processing a partial body. Add an integration test that checks a CGI or proxy endpoint receives the complete marker body.📍 Affects 2 files
src/mod_security3.c#L427-L441(this comment)src/msc_filters.c#L60-L65🤖 Prompt for AI Agents