summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2016-02-06 19:05:10 -0500
committerJarkko Hietaniemi <jhi@iki.fi>2016-02-07 08:23:46 -0500
commitf95ba548a286b17c260cc168715a9d0d441b14a6 (patch)
treeeebda5911c55241fbb6e60dab7d188ff40180885 /doio.c
parent9a28816aff195b1fd1ba9bcaa3db6eefd8ad70d4 (diff)
downloadperl-f95ba548a286b17c260cc168715a9d0d441b14a6.tar.gz
Check against negative uid/gid for fchown().
Coverity CID 135145: Argument cannot be negative (NEGATIVE_RETURNS)
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/doio.c b/doio.c
index d95ad9cd80..fc210d8a22 100644
--- a/doio.c
+++ b/doio.c
@@ -1824,8 +1824,18 @@ Perl_apply(pTHX_ I32 type, SV **mark, SV **sp)
int fd = PerlIO_fileno(IoIFP(GvIOn(gv)));
APPLY_TAINT_PROPER();
if (fd < 0) {
- SETERRNO(EBADF,RMS_IFI);
+ SETERRNO(EBADF,RMS_IFI);
+ tot--;
+#if Uid_t_sign == 1
+ } else if (val < 0) {
+ SETERRNO(EINVAL,LIB_INVARG);
tot--;
+#endif
+#if Gid_t_sign == 1
+ } else if (val2 < 0) {
+ SETERRNO(EINVAL,LIB_INVARG);
+ tot--;
+#endif
} else if (fchown(fd, val, val2))
tot--;
#else