Message264343
| Author |
martin.panter |
| Recipients |
Andrey Wagin, benjamin.peterson, berker.peksag, martin.panter |
| Date |
2016年04月27日.03:38:19 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1461728299.94.0.12703526832.issue24933@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
As far as I know, passing MSG_TRUNC into recv() is Linux-specific. I guess the "right" portable way to get a message size is to know it in advance, or guess and expand the buffer if MSG_PEEK cannot return the whole message.
Andrey: I don’t think we are accessing _unallocated_ memory (which could crash Python). If you look at _PyBytes_Resize(), I think it correctly allocates the memory, and just leaves it uninitialized.
Some options:
* Document that arbitrary flags like Linux’s MSG_TRUNC not supported
* Limit the returned buffer to the original buffer size
* Raise an exception or warning if recv() returns more than the original buffer size
* Reject unsupported flags like MSG_TRUNC
* Initialize the expanded buffer with zeros |
|