On Fri, Jul 12, 2019 at 10:34:33PM +0200, Moritz Buhl wrote:
> while running some ported tests I noticed that msgsnd(2) did not error
> when passing a message with mtype < 1, even tho the manual page states:
> > mtype is an integer greater than 0 that can be used
We also fail to mention that condition in the ERRORS section.
 
> Here is a minimal test:
> 
> #include <sys/msg.h>
> 
> struct msg {
What msgsnd(2) send takes should be of type `struct mymsg`, but our
manual page lackes the struct's name, so this could be improved as well.

> Index: sys/kern/sysv_msg.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/sysv_msg.c,v
> retrieving revision 1.34
> diff -u -p -r1.34 sysv_msg.c
> --- sys/kern/sysv_msg.c       5 Dec 2018 15:42:45 -0000       1.34
> +++ sys/kern/sysv_msg.c       12 Jul 2019 15:03:16 -0000
> @@ -588,7 +588,7 @@ msg_copyin(struct msg *msg, const char *
>               return (error);
>       }
>  
> -     if (msg->msg_type < 0) {
> +     if (msg->msg_type <= 0) {
OK kn, although I'd go with `< 1' as that matches the specification's
wording as well as what NetBSD and FreeBSD have in sysv_msg.c.

>               msg_free(msg);
>               return (EINVAL);
>       }
> 

Reply via email to