Module Name: src Committed By: snj Date: Tue Jul 21 00:23:01 UTC 2009
Modified Files: src/sys/kern [netbsd-5]: sys_mqueue.c Log Message: Pull up following revision(s) (requested by rmind in ticket #857): sys/kern/sys_mqueue.c: revision 1.21 via patch mq_send/mq_receive: while permission may allow that, return EBADF if sending to read-only queue, or receiving from write-only queue. >From Stathis Kamperis, thanks! To generate a diff of this commit: cvs rdiff -u -r1.12.4.3 -r1.12.4.4 src/sys/kern/sys_mqueue.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/sys_mqueue.c diff -u src/sys/kern/sys_mqueue.c:1.12.4.3 src/sys/kern/sys_mqueue.c:1.12.4.4 --- src/sys/kern/sys_mqueue.c:1.12.4.3 Wed May 27 21:32:05 2009 +++ src/sys/kern/sys_mqueue.c Tue Jul 21 00:23:01 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_mqueue.c,v 1.12.4.3 2009/05/27 21:32:05 snj Exp $ */ +/* $NetBSD: sys_mqueue.c,v 1.12.4.4 2009/07/21 00:23:01 snj Exp $ */ /* * Copyright (c) 2007, 2008 Mindaugas Rasiukevicius <rmind at NetBSD org> @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.12.4.3 2009/05/27 21:32:05 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_mqueue.c,v 1.12.4.4 2009/07/21 00:23:01 snj Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -482,9 +482,14 @@ /* Get the message queue */ error = mqueue_get(mqdes, &fp); - if (error) + if (error) { return error; + } mq = fp->f_data; + if ((fp->f_flag & FREAD) == 0) { + error = EBADF; + goto error; + } /* Check the message size limits */ if (msg_len < mq->mq_attrib.mq_msgsize) { @@ -642,6 +647,10 @@ return error; } mq = fp->f_data; + if ((fp->f_flag & FWRITE) == 0) { + error = EBADF; + goto error; + } /* Check the message size limit */ if (msg_len <= 0 || msg_len > mq->mq_attrib.mq_msgsize) {