◐ Shell
reader mode source ↗
Skip to content

bpo-9566: Fixed _ssl module warnings#2495

Merged
zooba merged 3 commits into
python:masterfrom
segevfiner:bpo-9566-ssl-warnings
Jul 26, 2017
Merged

bpo-9566: Fixed _ssl module warnings#2495
zooba merged 3 commits into
python:masterfrom
segevfiner:bpo-9566-ssl-warnings

Conversation

@segevfiner

@segevfiner segevfiner commented Jun 29, 2017

Copy link
Copy Markdown
Contributor

Split from #2492 on request by @Haypo

The following remain:

  • ..\Modules\_ssl.c(2947): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
    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?
  • ..\Modules\_ssl.c(4158): warning C4244: 'function': conversion from 'Py_ssize_t' to 'int', possible loss of data
    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

@mention-bot

Copy link
Copy Markdown

@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.

@vstinner

Copy link
Copy Markdown
Member
..\Modules\_ssl.c(2947): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
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?

_ssl__SSLContext__set_alpn_protocols_impl(). You must check for overflow manually: "if (len > INT_MAX) raise an exception;".

..\Modules\_ssl.c(4158): warning C4244: 'function': conversion from 'Py_ssize_t' to 'int', possible loss of data
Someone can theoretically pass a buffer big enough...

_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.

@segevfiner

Copy link
Copy Markdown
Contributor Author

@Haypo

_ssl__SSLContext__set_alpn_protocols_impl(). You must check for overflow manually: "if (len > INT_MAX) raise an exception;".

PySSLContext.alpn_protocols_len was actually an int while it is treated as an unsigned int everywhere, so I changed it for correctness.

@segevfiner segevfiner changed the title [WIP] bpo-9566: Fixed some _ssl module warnings Jun 30, 2017
@segevfiner segevfiner changed the title bpo-9566: Fixed some _ssl module warnings Jun 30, 2017
@zooba

zooba commented Jul 26, 2017

Copy link
Copy Markdown
Member

The changes requested by @Haypo have been made, so I'm merging.

@zooba zooba merged commit 5cff637 into python:master Jul 26, 2017
@segevfiner segevfiner deleted the bpo-9566-ssl-warnings branch July 26, 2017 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants