From 0fb997733a0bb4e3f7a0c073c19a2e302be1fbae Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Tue, 6 Dec 2011 00:30:30 +0100 Subject: 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 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'pfinet') diff --git a/pfinet/socket-ops.c b/pfinet/socket-ops.c index 02675425..b4172dc4 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); -- cgit v1.2.3