Make msgsnd(2)/msgrcv(2) fail with EINVAL for messages larger than

SSIZE_MAX. Adjust man pages accordingly.

ok by christos.
This commit is contained in:
njoly 2009-01-26 13:08:48 +00:00
parent 3e5b27ff8e
commit 122f627e90
3 changed files with 18 additions and 7 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: msgrcv.2,v 1.17 2004/05/13 10:20:58 wiz Exp $
.\" $NetBSD: msgrcv.2,v 1.18 2009/01/26 13:08:48 njoly Exp $
.\"
.\" Copyright (c) 1995 Frank van der Linden
.\" All rights reserved.
@ -173,7 +173,8 @@ The message queue was removed while
was waiting for a message of the requested type to become available in it.
.Pp
.Fa msgsz
is less than 0.
is greater than
.Dv SSIZE_MAX .
.It Bq Er E2BIG
A matching message was received, but its size was greater than
.Fa msgsz

View File

@ -1,4 +1,4 @@
.\" $NetBSD: msgsnd.2,v 1.15 2004/05/13 10:20:58 wiz Exp $
.\" $NetBSD: msgsnd.2,v 1.16 2009/01/26 13:08:48 njoly Exp $
.\"
.\" Copyright (c) 1995 Frank van der Linden
.\" All rights reserved.
@ -141,8 +141,10 @@ was waiting for a resource to become available in order to deliver the
message.
.Pp
.Fa msgsz
is less than 0, or greater than
.Va msg_qbytes .
is greater than
.Va msg_qbytes
or
.Dv SSIZE_MAX .
.It Bq Er EACCES
The calling process does not have write access to the message queue.
.It Bq Er EAGAIN

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysv_msg.c,v 1.59 2009/01/11 02:45:53 christos Exp $ */
/* $NetBSD: sysv_msg.c,v 1.60 2009/01/26 13:08:48 njoly Exp $ */
/*-
* Copyright (c) 1999, 2006, 2007 The NetBSD Foundation, Inc.
@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sysv_msg.c,v 1.59 2009/01/11 02:45:53 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: sysv_msg.c,v 1.60 2009/01/26 13:08:48 njoly Exp $");
#define SYSVMSG
@ -653,6 +653,10 @@ msgsnd1(struct lwp *l, int msqidr, const char *user_msgp, size_t msgsz,
MSG_PRINTF(("call to msgsnd(%d, %p, %lld, %d)\n", msqid, user_msgp,
(long long)msgsz, msgflg));
if ((ssize_t)msgsz < 0)
return EINVAL;
restart:
msqid = IPCID_TO_IX(msqidr);
@ -959,6 +963,10 @@ msgrcv1(struct lwp *l, int msqidr, char *user_msgp, size_t msgsz, long msgtyp,
MSG_PRINTF(("call to msgrcv(%d, %p, %lld, %ld, %d)\n", msqid,
user_msgp, (long long)msgsz, msgtyp, msgflg));
if ((ssize_t)msgsz < 0)
return EINVAL;
restart:
msqid = IPCID_TO_IX(msqidr);