Skip to content

Commit

Permalink
doc/man3/SSL_set_fd.pod: add note about Windows compiler warning
Browse files Browse the repository at this point in the history
According to an old stackoverflow thread [1], citing an even older comment by
Andy Polyakov (1875e6d, Pull up Win64 support from 0.9.8., 2005-07-05),
a cast of 'SOCKET' (UINT_PTR) to 'int' does not create a problem, because although
the documentation [2] claims that the upper limit is INVALID_SOCKET-1 (2^64 - 2),
in practice the socket() implementation on Windows returns an index into the kernel
handle table, the size of which is limited to 2^24 [3].

Add this note to the manual page to avoid unnecessary roundtrips to StackOverflow.

[1] https://stackoverflow.com/questions/1953639/is-it-safe-to-cast-socket-to-int-under-win64
[2] https://docs.microsoft.com/en-us/windows/win32/winsock/socket-data-type-2
[3] https://docs.microsoft.com/en-us/windows/win32/sysinfo/kernel-objects

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #16699)
  • Loading branch information
mspncp committed Sep 30, 2021
1 parent 611685a commit f8dd586
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions doc/man3/SSL_set_fd.pod
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ The operation succeeded.

=back

=head1 NOTES

On Windows, a socket handle is a 64-bit data type (UINT_PTR), which leads to a
compiler warning (conversion from 'SOCKET' to 'int', possible loss of data) when
passing the socket handle to SSL_set_*fd(). For the time being, this warning can
safely be ignored, because although the Microsoft documentation claims that the
upper limit is INVALID_SOCKET-1 (2^64 - 2), in practice the current socket()
implementation returns an index into the kernel handle table, the size of which
is limited to 2^24.


=head1 SEE ALSO

L<SSL_get_fd(3)>, L<SSL_set_bio(3)>,
Expand Down

0 comments on commit f8dd586

Please sign in to comment.