This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
msgsnd id can be invalid.
authorJarkko Hietaniemi <jhi@iki.fi>
Tue, 23 Jun 2015 11:26:46 +0000 (07:26 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Sat, 27 Jun 2015 03:09:42 +0000 (23:09 -0400)
Coverity CID 104833.

doio.c

diff --git a/doio.c b/doio.c
index 79ab20c..ee93ece 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -2340,7 +2340,12 @@ Perl_do_msgsnd(pTHX_ SV **mark, SV **sp)
     if (msize < 0)
        Perl_croak(aTHX_ "Arg too short for msgsnd");
     SETERRNO(0,0);
-    return msgsnd(id, (struct msgbuf *)mbuf, msize, flags);
+    if (id >= 0 && flags >= 0) {
+      return msgsnd(id, (struct msgbuf *)mbuf, msize, flags);
+    } else {
+      SETERRNO(EINVAL,LIB_INVARG);
+      return -1;
+    }
 #else
     PERL_UNUSED_ARG(sp);
     PERL_UNUSED_ARG(mark);