-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Fixed #21231 -- Enforced a max size for GET/POST values read into memory. #6447
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
Conversation
LGTM Thanks for the help! |
@edevil, what do you think about also limiting the reads for |
@timgraham That check was present in the patch, but I was asked to remove it. I can't find the commit anymore since I have consolidated commits several times already. In my opinion that check should be there. |
django/http/request.py
Outdated
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.
Is dropping the initial ''
argument to QueryDict
here intentional? Does it have any effect?
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.
No behavior change since d68987a. For clarity, I can change all instances in Django in a separate commit.
I'd agree that a check on |
django/http/multipartparser.py
Outdated
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.
I'd probably rather see us do read_size = settings.DATA_UPLOAD_MAX_MEMORY_SIZE + 1 - self._data_size
and then drop the field_stream.read(1)
. I think that might be very marginally clearer. Either way reasonable tho'.
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.
Done this although it seems there might be a missing test as none fail if removing the "+ 1" (or the field_stream.read(1)
in the earlier version of the patch).
@timgraham @tomchristie I don't see the problem with the previous patch 620ab2a. The check was not on |
django/http/multipartparser.py
Outdated
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.
This one would still make marginally more sense as a variable in the parse
method, right?
Was the complaint about the |
It was, and @apollo13 also weighed in:
I can't find this comment on github anymore, probably because the history was re-written. |
I'm also not seeing how that includes file uploads. I added |
Likewise. MultipartParser uses the stream interface so the body check seems valid to me too. |
The latest commit moves the check back to |
django/http/multipartparser.py
Outdated
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.
@edevil, do you have time to investigate this TODO?
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.
I don't remember anymore the specific details of this... It seems to me that the idea was to read 1 more than the max so that the max would still be valid. The test bellow is: data_size > settings.DATA_UPLOAD_MAX_MEMORY_SIZE
. But since we're already adding len(field_name) + 2
on top of what we read this seems pointless now.
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.
But since we're already adding len(field_name) + 2 on top of what we read this seems pointless now.
Good point.
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.
Removed. Ready for merge now?
django/http/multipartparser.py
Outdated
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.
Having this around L152 would be very marginally cleaner from my POV. (Ie. it's similar to num_post_keys
so makes sense for it to get initialized at same point in the codebase)
One inconsequential style tweak noted above. Otherwise I've no remaining concerns. |
…ory. Thanks Tom Christie for review.
Woah! Finally. Thanks for the work! |
Updated from #3852.
https://code.djangoproject.com/ticket/21231