Martin Panter added the comment: 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 ---------- components: +Extension Modules -Library (Lib) nosy: +martin.panter _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24933> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com