This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
tcsetattr optional_actions can be invalid.
authorJarkko Hietaniemi <jhi@iki.fi>
Thu, 25 Jun 2015 12:56:59 +0000 (08:56 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Sat, 27 Jun 2015 03:09:42 +0000 (23:09 -0400)
Coverity CID 104815.

ext/POSIX/POSIX.xs

index ba986bb..216c47e 100644 (file)
@@ -1958,7 +1958,12 @@ setattr(termios_ref, fd = 0, optional_actions = DEF_SETATTR_ACTION)
                it a useful default. 0 isn't valid on all operating systems - on
                Solaris (at least) TCSANOW, TCSADRAIN and TCSAFLUSH have the same
                values as the equivalent ioctls, TCSETS, TCSETSW and TCSETSF.  */
                it a useful default. 0 isn't valid on all operating systems - on
                Solaris (at least) TCSANOW, TCSADRAIN and TCSAFLUSH have the same
                values as the equivalent ioctls, TCSETS, TCSETSW and TCSETSF.  */
-            RETVAL = tcsetattr(fd, optional_actions, termios_ref);
+            if (optional_actions < 0) {
+               SETERRNO(EINVAL, LIB_INVARG);
+               RETVAL = -1;
+            } else {
+                RETVAL = tcsetattr(fd, optional_actions, termios_ref);
+            }
         } else {
             SETERRNO(EBADF,RMS_IFI);
             RETVAL = -1;
         } else {
             SETERRNO(EBADF,RMS_IFI);
             RETVAL = -1;