-
-
Couldn't load subscription status.
- Fork 33.2k
gh-119511: Fix OOM vulnerability in imaplib #119514
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
Changes from 1 commit
6322049
284a553
d7abc31
1c74be4
d71a7ee
f6a41df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,9 @@ | |
| # search command can be quite large, so we now use 1M. | ||
| _MAXLINE = 1000000 | ||
|
|
||
| # Data larger than this will be read in chunks, to prevent extreme | ||
| # overallocation. | ||
| _SAFE_BUF_SIZE = 1 << 20 | ||
|
|
||
| # Commands | ||
|
|
||
|
|
@@ -315,6 +318,13 @@ def open(self, host='', port=IMAP4_PORT, timeout=None): | |
|
|
||
| def read(self, size): | ||
| """Read 'size' bytes from remote.""" | ||
| cursize = min(size, _SAFE_BUF_SIZE) | ||
| data = self.file.read(cursize) | ||
| while cursize < size and len(data) == cursize: | ||
| delta = min(cursize, size - cursize) | ||
| data += self.file.read(delta) | ||
| cursize += delta | ||
| return data | ||
| return self.file.read(size) | ||
|
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix a vulnerability in the :mod:`imaplib` module, when connecting to a | ||
| malicious server could cause an arbitrary amount of memory to be consumed. |
Uh oh!
There was an error while loading. Please reload this page.