-
Notifications
You must be signed in to change notification settings - Fork 591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Do not merge]fs/mqueue/mq_check.c: group level error check for mq operations #6570
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,6 +161,11 @@ int mq_notify(mqd_t mqdes, const struct sigevent *notification) | |
return ERROR; | ||
} | ||
|
||
if (mq_desc_in_grouplist(mqdes) != OK) { | ||
set_errno(EBADF); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you should use the return value instead of hard coding here. |
||
return ERROR; | ||
} | ||
|
||
/* Get a pointer to the message queue */ | ||
|
||
msgq = mqdes->msgq; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,6 +125,7 @@ | |
* message queue. | ||
* EINTR The call was interrupted by a signal handler. | ||
* EINVAL Invalid 'msg' or 'mqdes' | ||
* EBADF Mqdes is not present in calling task group's mq list. | ||
* | ||
* Assumptions: | ||
* | ||
|
@@ -145,6 +146,12 @@ ssize_t mq_receive(mqd_t mqdes, FAR char *msg, size_t msglen, FAR int *prio) | |
/* mq_receive() is a cancellation point */ | ||
(void)enter_cancellation_point(); | ||
|
||
if (mq_desc_in_grouplist(mqdes) != OK) { | ||
leave_cancellation_point(); | ||
set_errno(EBADF); | ||
return ERROR; | ||
} | ||
|
||
if (mq_verifyreceive(mqdes, msg, msglen) != OK) { | ||
leave_cancellation_point(); | ||
return ERROR; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before ERROR return, we should set proper errno.
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,6 +124,7 @@ | |
* EAGAIN The queue was empty, and the O_NONBLOCK flag was set for the | ||
* message queue description referred to by mqdes. | ||
* EINVAL Either msg or mqdes is NULL or the value of prio is invalid. | ||
* EBADF Mqdes is not present in calling task group's mq list. | ||
* EPERM Message queue opened not opened for writing. | ||
* EMSGSIZE 'msglen' was greater than the maxmsgsize attribute of the | ||
* message queue. | ||
|
@@ -149,6 +150,12 @@ int mq_send(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio) | |
/* mq_send() is a cancellation point */ | ||
(void)enter_cancellation_point(); | ||
|
||
if (mq_desc_in_grouplist(mqdes) != OK) { | ||
leave_cancellation_point(); | ||
set_errno(EBADF); | ||
return ERROR; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check needs to be done in all mq apis. Please check timedsend and timed receive. |
||
if (mq_verifysend(mqdes, msg, msglen, prio) != OK) { | ||
leave_cancellation_point(); | ||
return ERROR; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as previous |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ | |
|
||
#include <fcntl.h> /* O_NONBLOCK */ | ||
#include <mqueue.h> | ||
#include <errno.h> | ||
|
||
#include <tinyara/mqueue.h> | ||
|
||
|
@@ -114,6 +115,11 @@ int mq_setattr(mqd_t mqdes, const struct mq_attr *mq_stat, struct mq_attr *oldst | |
{ | ||
int ret = ERROR; | ||
|
||
if (mq_desc_in_grouplist(mqdes) != OK) { | ||
set_errno(EBADF); | ||
return ERROR; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set errno is missnig |
||
} | ||
|
||
if (mqdes && mq_stat) { | ||
/* Return the attributes if so requested */ | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to set the errno before we return.