[PATCH] handle EPROTOTYPE for socket invocations with SOCK_* flags

Pino Toscano toscano.pino@tiscali.it
Thu Feb 7 22:29:00 GMT 2013


Alle giovedì 7 febbraio 2013, Roland McGrath ha scritto:
> > The snippets of fallback code that handle failures of invocation of
> > socket with SOCK_CLOEXEC or SOCK_NONBLOCK seem to not correctly
> > disable have_sock_cloexec/__have_sock_cloexec if errno is
> > EPROTOTYPE, as returned when the socket type (like "SOCK_STREAM |
> > SOCK_CLOEXEC" for socket with no handling of flags) is unknown.
> 
> There seem to be multiple errno values that could indicate this. 
> POSIX specifies that socket shall fail with EPROTOTYPE if "The
> socket type is not supported by the protocol."  This could be
> construed as applying only if the type value is valid in general and
> is not supported by the particular protocol.  By that reading, it
> still conforms to POSIX if socket uses any errno code it likes
> (except those specified for other error cases of socket, like
> EAFNOSUPPORT; EINVAL is not specified for socket).

I'm not sure to agree with this interpretation though, since IMHO the 
validation of the socket type should depend on the previous validation 
of the protocol.

> Arguably we should harmonize the Hurd's use of errno codes here
> either to Linux or to BSD.  That is, unless someone gets a
> clarification from the POSIX committee and that says that the
> behavior is nonconforming.  (I'm not really clear on how it could
> be, since you have to write a nonconforming program to elicit these
> errors.)

Please bear with me, but I still don't understand what would be the 
issue with Hurd's errno codes, in this case; are you implying Hurd 
should behave e.g. like Linux and return EINVAL for "high" invalid 
values of socket types?

Updated version of the patch: I introduced a new __-prefixed function 
versioned as GLIBC_PRIVATE to be used also outside libc (libresolv and 
nscd), I hope to have done it correctly.

-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: no_sock_cloexec.diff
Type: text/x-patch
Size: 4667 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20130207/93c70dad/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20130207/93c70dad/attachment.sig>


More information about the Libc-alpha mailing list