bitwiseworks / libc

LIBC Next (kLIBC fork)
9 stars 4 forks source link

socklen_t is defined as unsigned int not int #134

Closed komh closed 11 months ago

komh commented 11 months ago

Hi/2.

OS/2 TCP/IP uses int for socklen_t. However, LIBCn typedefs socklen_t as unsigned int here:

https://github.com/bitwiseworks/libc/blob/b246be5f6d3d9ff751e1d527dc3a945fbaf1ed76/src/emx/include/sys/_types.h#L71

Is this mismatch intentional ?

dmik commented 11 months ago

Yes, this is intentional, see https://github.com/bitwiseworks/libc/issues/63. The current definition is expected by POSIX and many modern software. The (in)compatibility with the very old OS/2 TCP/IP headers is really not a big issue, see also #137.

komh commented 11 months ago

I'm worrying about binary compatibility. If a value of socklen_t is larger than 2^31 - 1, OS/2 TCP/IP will accept it as a negative value. Is this not a problem?

dmik commented 11 months ago

This isn't actually a problem. The OS/2 TCP/IP stack is 16-bit, so the largest possible number it can operates is 2^16-1 (65535). Also, even if it were 32-bit, it's impossible to imagine it operating a 2GB buffer (2^31-1) — you will rarely (if at all) get a single memory region from OS/2 that large.