Description
Summary
Networking implementation in the library follows POSIX standards, but the same code is used on Windows too.
mbedtls/include/mbedtls/net_sockets.h
Line 90 in f19a08f
There are no standard options to change this declaration, though Windows declares socket as unsigned pointer-sized integer.
The current code has two negative properties:
- Implicit type casts between 32-bit/64-bit unsigned integers and 32-bit signed integers - with potential loss of data.
- Check for invalid socket is not quite correct, because there is one specific value on Windows, not any negative number.
System information
Mbed TLS version (number or commit id): any
Operating system and version: Windows
Configuration (if not default, please attach mbedtls_config.h
):
Compiler and options (if you used a pre-built binary, please indicate how you obtained it):
Additional environment information:
Expected behavior
Using native socket type and error checks on Windows.
Actual behavior
Mbedtls always uses 32-bit signed integer for sockets; any negative value means invalid socket
.
Signed/unsigned mismatch and truncation/expansion of values are commonly diagnosed by compilers and static analysers.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Status