linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* error handling recvfrom(2)
@ 2025-03-27 11:45 Peter Radisson
  0 siblings, 0 replies; only message in thread
From: Peter Radisson @ 2025-03-27 11:45 UTC (permalink / raw)
  To: linux-api

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




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-03-27 11:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-27 11:45 error handling recvfrom(2) Peter Radisson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).