diff --git a/fs/mqueue/mq_open.c b/fs/mqueue/mq_open.c index 627e57f4dd..d561439ef0 100644 --- a/fs/mqueue/mq_open.c +++ b/fs/mqueue/mq_open.c @@ -191,6 +191,11 @@ static int file_mq_vopen(FAR struct file *mq, FAR const char *mq_name, mode = va_arg(ap, mode_t); attr = va_arg(ap, FAR struct mq_attr *); + if (attr->mq_maxmsg <= 0 || attr->mq_msgsize <= 0) + { + ret = -EINVAL; + goto errout; + } } mode &= ~umask; diff --git a/include/mqueue.h b/include/mqueue.h index ed3d271c66..361e8e66fd 100644 --- a/include/mqueue.h +++ b/include/mqueue.h @@ -42,10 +42,10 @@ struct mq_attr { - size_t mq_maxmsg; /* Max number of messages in queue */ - size_t mq_msgsize; /* Max message size */ - unsigned mq_flags; /* Queue flags */ - size_t mq_curmsgs; /* Number of messages currently in queue */ + long mq_maxmsg; /* Max number of messages in queue */ + long mq_msgsize; /* Max message size */ + long mq_flags; /* Queue flags */ + long mq_curmsgs; /* Number of messages currently in queue */ }; /* Message queue descriptor */