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

doio.c

diff --git a/doio.c b/doio.c
index ee93ece..2dfd5f4 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -2378,7 +2378,12 @@ Perl_do_msgrcv(pTHX_ SV **mark, SV **sp)
     mbuf = SvGROW(mstr, sizeof(long)+msize+1);
 
     SETERRNO(0,0);
-    ret = msgrcv(id, (struct msgbuf *)mbuf, msize, mtype, flags);
+    if (id >= 0 && msize >= 0 && flags >= 0) {
+        ret = msgrcv(id, (struct msgbuf *)mbuf, msize, mtype, flags);
+    } else {
+        SETERRNO(EINVAL,LIB_INVARG);
+        ret = -1;
+    }
     if (ret >= 0) {
        SvCUR_set(mstr, sizeof(long)+ret);
        *SvEND(mstr) = '\0';