@@ -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) {