From 904cbb3dbf1478995629f0cfb83713de786c25e8 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Tue, 6 Dec 2011 00:30:30 +0100 Subject: [PATCH] Fix error values on socket creation On socket creation, return the correct errno values, EPROTOTYPE and EPROTONOSUPPORT, for invalid socket types and protocols. * pfinet/socket-ops.c (S_socket_create): Correctly return EPROTOTYPE and EPROTONOSUPPORT. * pflocal/pf.c (S_socket_create): Correctly return EPROTOTYPE. --- pfinet/socket-ops.c | 14 ++++++++------ pflocal/pf.c | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pfinet/socket-ops.c b/pfinet/socket-ops.c index 0267542..b4172dc 100644 --- a/pfinet/socket-ops.c +++ b/pfinet/socket-ops.c @@ -51,12 +51,14 @@ S_socket_create (struct trivfs_protid *master, /* Don't allow bogus SOCK_PACKET here. */ - if ((sock_type != SOCK_STREAM - && sock_type != SOCK_DGRAM - && sock_type != SOCK_SEQPACKET - && sock_type != SOCK_RAW) - || protocol < 0) - return EINVAL; + if (sock_type != SOCK_STREAM + && sock_type != SOCK_DGRAM + && sock_type != SOCK_SEQPACKET + && sock_type != SOCK_RAW) + return EPROTOTYPE; + + if (protocol < 0) + return EPROTONOSUPPORT; __mutex_lock (&global_lock); diff --git a/pflocal/pf.c b/pflocal/pf.c index 32c12e1..55824d4 100644 --- a/pflocal/pf.c +++ b/pflocal/pf.c @@ -65,7 +65,7 @@ S_socket_create (mach_port_t pf, case SOCK_SEQPACKET: pipe_class = seqpack_pipe_class; break; default: - return ESOCKTNOSUPPORT; + return EPROTOTYPE; } err = sock_create (pipe_class, mode, &sock); -- 1.7.7.3