Skip to content

Exit more gracefully if uri length is zero #173

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

Closed
wants to merge 1 commit into from
Closed

Exit more gracefully if uri length is zero #173

wants to merge 1 commit into from

Conversation

martinhsv
Copy link
Contributor

No description provided.

@@ -150,6 +150,10 @@ ngx_http_modsecurity_rewrite_handler(ngx_http_request_t *r)
if (n_uri == (char*)-1 || n_method == (char*)-1) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure whether the better way is to change this check in a way like if (n_uri == NULL || n_method == NULL)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Assuming we want to leave the utility function ngx_str_to_char unchanged, it effectively has two different error return values: NULL, and (char *)-1. In that case it's useful to retain the existing line 150 check ... but then in addition also check for n_uri == NULL (the error use case that was occurring in owasp-modsecurity/ModSecurity#2216). We could of course also add a check for n_method==NULL, but I was focussed solely on improving the error handling for the case that we actually saw.

@zimmerle
Copy link
Contributor

This is merged! Thank you!

@zimmerle zimmerle closed this Feb 17, 2020
@zimmerle zimmerle self-assigned this Feb 17, 2020
@zimmerle zimmerle self-requested a review February 17, 2020 13:17
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.

3 participants