| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
@segevfiner, thanks for your PR! By analyzing the history of the files in this pull request, we identified @pitrou, @tiran and @serhiy-storchaka to be potential reviewers. |
Sorry, something went wrong.
| cipher_id = SSL_CIPHER_get_id(cipher); | ||
| SSL_CIPHER_description(cipher, buf, sizeof(buf) - 1); | ||
| len = strlen(buf); | ||
| len = (int)strlen(buf); |
There was a problem hiding this comment.
buf is 512 bytes long and always ends with a null byte, so the downcast is safe.
Sorry, something went wrong.
There was a problem hiding this comment.
Right, and by explicitly stating that we are intentionally downcasting, someone who is reading the code can recognize that without having to do the flow analysis themselves. (Also, the compiler will recognize it too, and stop showing a warning.)
Sorry, something went wrong.
| PyObject *result; | ||
|
|
||
| avail = BIO_ctrl_pending(self->bio); | ||
| avail = (int)BIO_ctrl_pending(self->bio); |
There was a problem hiding this comment.
I dislike this downcast. I would prefer to use a larger integer type.
https://linux.die.net/man/3/bio_ctrl_pending says that the return type is size_t, it's unsigned. We may have to check < PY_SSIZE_T_MAX before downcasting to Py_ssize_t.
Sorry, something went wrong.
There was a problem hiding this comment.
BIO_read takes an int so we can only really only read as much as an int can hold without calling BIO_read in a loop. I replaced this with a Py_MIN which will make us read up to INT_MAX.
Sorry, something went wrong.
_ssl__SSLContext__set_alpn_protocols_impl(). You must check for overflow manually: "if (len > INT_MAX) raise an exception;".
_ssl_MemoryBIO_write_impl(): you cannot, there is "if (b->len > INT_MAX) { ... }" a few lines before, so the downcast is safe. Make it explicit with a "(int)" cast. |
Sorry, something went wrong.
PySSLContext.alpn_protocols_len was actually an int while it is treated as an unsigned int everywhere, so I changed it for correctness. |
Sorry, something went wrong.
| cipher_id = SSL_CIPHER_get_id(cipher); | ||
| SSL_CIPHER_description(cipher, buf, sizeof(buf) - 1); | ||
| len = strlen(buf); | ||
| len = (int)strlen(buf); |
There was a problem hiding this comment.
Right, and by explicitly stating that we are intentionally downcasting, someone who is reading the code can recognize that without having to do the flow analysis themselves. (Also, the compiler will recognize it too, and stop showing a warning.)
Sorry, something went wrong.
|
The changes requested by @Haypo have been made, so I'm merging. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Split from #2492 on request by @Haypo
The following remain:
The Py_buffer can theoretically be larger... But I'm not sure that the protocol even supports that...
Should this be casted away or fixed some other way?
Someone can theoretically pass a buffer big enough... But I doubt such a buffer is going to be written at once...
Should this be casted away...?
https://bugs.python.org/issue9566