Skip to contentSkip to conversation

error handling recvfrom(2)

DISCUSSION Peter Radisson 1 participant 1 message Mar 27, 2025 ABI/API

lore
Share & tools
lore
#0 lore raw

Hi list,

I noted the error handling in recvfrom(2) is wired. note i will only talk about src_addr and addrlen in the case src_addr != NULL. I have tested with kernel 5.14.

Function: the kernel shall fill the user supplied structure in src_addr what should be addrlen in size (should be sizeof struct sockaddr ).

regarding addrlen i found the follwing behavier:

addrlen < 0 errno=EINVAL
0<= addrlen < sizeof struct sockaddr no errno set

IMHO recvfrom(2) should report an error here also.

while testing i noted that the case addrlen < 0 is checked after the call. What means if you use a blocking recvfrom, the call waits for an answer only to report an error afterwards.

IMHO the check for space should be done before.

What is the rationale behind this ?
If not can that be changed ?

note: please reply directly i am not a list member
note: I send also a mail to the man-page list to improve the
documentation of the current state

CU