Expand system() arguments before a fork
This commit is contained in:
parent
4440ffe366
commit
ef39cf486c
90
perl-5.26.1-perform-system-arg-processing-before-fork.patch
Normal file
90
perl-5.26.1-perform-system-arg-processing-before-fork.patch
Normal file
@ -0,0 +1,90 @@
|
||||
From cbe3025c652289aee2f2f4145f882be5b33a27ee Mon Sep 17 00:00:00 2001
|
||||
From: Zefram <zefram@fysh.org>
|
||||
Date: Sat, 16 Dec 2017 05:33:20 +0000
|
||||
Subject: [PATCH] perform system() arg processing before fork
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
A lot of things can happen when stringifying an argument list: side
|
||||
effects, warnings, exceptions. In the case of system(), these effects
|
||||
should happen in the context of the parent process. The stringification
|
||||
can also depend on which process it happens in, as in the case of
|
||||
$$, and in that case it should also happen in the parent process.
|
||||
Therefore reduce the argument scalars to strings first thing in pp_system.
|
||||
Fixes [perl #121105].
|
||||
|
||||
Petr Písař: Ported to 5.26.1 from
|
||||
64def2aeaeb63f92dadc6dfa33486c1d7b311963.
|
||||
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||
---
|
||||
pp_sys.c | 16 ++++++++++------
|
||||
t/op/exec.t | 15 ++++++++++++++-
|
||||
2 files changed, 24 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/pp_sys.c b/pp_sys.c
|
||||
index 87961f1..07e552a 100644
|
||||
--- a/pp_sys.c
|
||||
+++ b/pp_sys.c
|
||||
@@ -4375,14 +4375,18 @@ PP(pp_system)
|
||||
int result;
|
||||
# endif
|
||||
|
||||
+ while (++MARK <= SP) {
|
||||
+ SV *origsv = *MARK;
|
||||
+ STRLEN len;
|
||||
+ char *pv;
|
||||
+ pv = SvPV(origsv, len);
|
||||
+ *MARK = newSVpvn_flags(pv, len,
|
||||
+ (SvFLAGS(origsv) & SVf_UTF8) | SVs_TEMP);
|
||||
+ }
|
||||
+ MARK = ORIGMARK;
|
||||
+
|
||||
if (TAINTING_get) {
|
||||
TAINT_ENV();
|
||||
- while (++MARK <= SP) {
|
||||
- (void)SvPV_nolen_const(*MARK); /* stringify for taint check */
|
||||
- if (TAINT_get)
|
||||
- break;
|
||||
- }
|
||||
- MARK = ORIGMARK;
|
||||
TAINT_PROPER("system");
|
||||
}
|
||||
PERL_FLUSHALL_FOR_CHILD;
|
||||
diff --git a/t/op/exec.t b/t/op/exec.t
|
||||
index 1155439..45237e9 100644
|
||||
--- a/t/op/exec.t
|
||||
+++ b/t/op/exec.t
|
||||
@@ -36,7 +36,7 @@ $ENV{LANGUAGE} = 'C'; # Ditto in GNU.
|
||||
my $Is_VMS = $^O eq 'VMS';
|
||||
my $Is_Win32 = $^O eq 'MSWin32';
|
||||
|
||||
-plan(tests => 25);
|
||||
+plan(tests => 28);
|
||||
|
||||
my $Perl = which_perl();
|
||||
|
||||
@@ -156,6 +156,19 @@ TODO: {
|
||||
"exec failure doesn't terminate process");
|
||||
}
|
||||
|
||||
+package CountRead {
|
||||
+ sub TIESCALAR { bless({ n => 0 }, $_[0]) }
|
||||
+ sub FETCH { ++$_[0]->{n} }
|
||||
+}
|
||||
+my $cr;
|
||||
+tie $cr, "CountRead";
|
||||
+is system($^X, "-e", "exit(\$ARGV[0] eq '1' ? 0 : 1)", $cr), 0,
|
||||
+ "system args have magic processed exactly once";
|
||||
+is tied($cr)->{n}, 1, "system args have magic processed before fork";
|
||||
+
|
||||
+is system($^X, "-e", "exit(\$ARGV[0] eq \$ARGV[1] ? 0 : 1)", "$$", $$), 0,
|
||||
+ "system args have magic processed before fork";
|
||||
+
|
||||
my $test = curr_test();
|
||||
exec $Perl, '-le', qq{${quote}print 'ok $test - exec PROG, LIST'${quote}};
|
||||
fail("This should never be reached if the exec() worked");
|
||||
--
|
||||
2.13.6
|
||||
|
@ -0,0 +1,34 @@
|
||||
From 8e7c2faafb74d3b07e8a5818608dfe065e361604 Mon Sep 17 00:00:00 2001
|
||||
From: "Craig A. Berry" <craigberry@mac.com>
|
||||
Date: Mon, 1 Jan 2018 10:10:33 -0600
|
||||
Subject: [PATCH] Reenable numeric first argument of system() on VMS.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This was broken in 64def2aeaeb63f92dadc6dfa334, and fixed for Win32
|
||||
only in 8fe3452cc6ac7af8c08. But VMS also uses a numeric first
|
||||
argument to system() as a flag indicating spawn without waiting for
|
||||
completion.
|
||||
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||
---
|
||||
pp_sys.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/pp_sys.c b/pp_sys.c
|
||||
index 0c9147bc4e..5154b9baa8 100644
|
||||
--- a/pp_sys.c
|
||||
+++ b/pp_sys.c
|
||||
@@ -4375,7 +4375,7 @@ PP(pp_system)
|
||||
STRLEN len;
|
||||
char *pv;
|
||||
SvGETMAGIC(origsv);
|
||||
-#ifdef WIN32
|
||||
+#if defined(WIN32) || defined(__VMS)
|
||||
/*
|
||||
* Because of a nasty platform-specific variation on the meaning
|
||||
* of arguments to this op, we must preserve numeric arguments
|
||||
--
|
||||
2.13.6
|
||||
|
@ -0,0 +1,73 @@
|
||||
From 8fe3452cc6ac7af8c08c2044cd3757018a9c8887 Mon Sep 17 00:00:00 2001
|
||||
From: Zefram <zefram@fysh.org>
|
||||
Date: Fri, 22 Dec 2017 05:32:41 +0000
|
||||
Subject: [PATCH] preserve numericness of system() args on Win32
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
On Windows there's a nasty variation in the meaning of arguments
|
||||
to Perl's system(), in which a numeric first argument isn't used as
|
||||
part of the command to run, but instead selects between two different
|
||||
operations to perform with the command (whether to wait for the command
|
||||
to complete or not). Therefore the reduction of argument scalars to
|
||||
their operative values in the parent process, which was added in commit
|
||||
64def2aeaeb63f92dadc6dfa33486c1d7b311963, needs to preserve numericness
|
||||
of arguments on Windows. Fixes [perl #132633].
|
||||
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||
---
|
||||
pp_sys.c | 35 +++++++++++++++++++++++++++++++----
|
||||
1 file changed, 31 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/pp_sys.c b/pp_sys.c
|
||||
index beb60da4c6..0649794104 100644
|
||||
--- a/pp_sys.c
|
||||
+++ b/pp_sys.c
|
||||
@@ -4393,12 +4393,39 @@ PP(pp_system)
|
||||
# endif
|
||||
|
||||
while (++MARK <= SP) {
|
||||
- SV *origsv = *MARK;
|
||||
+ SV *origsv = *MARK, *copysv;
|
||||
STRLEN len;
|
||||
char *pv;
|
||||
- pv = SvPV(origsv, len);
|
||||
- *MARK = newSVpvn_flags(pv, len,
|
||||
- (SvFLAGS(origsv) & SVf_UTF8) | SVs_TEMP);
|
||||
+ SvGETMAGIC(origsv);
|
||||
+#ifdef WIN32
|
||||
+ /*
|
||||
+ * Because of a nasty platform-specific variation on the meaning
|
||||
+ * of arguments to this op, we must preserve numeric arguments
|
||||
+ * as numeric, not just retain the string value.
|
||||
+ */
|
||||
+ if (SvNIOK(origsv) || SvNIOKp(origsv)) {
|
||||
+ copysv = newSV_type(SVt_PVNV);
|
||||
+ sv_2mortal(copysv);
|
||||
+ if (SvPOK(origsv) || SvPOKp(origsv)) {
|
||||
+ pv = SvPV_nomg(origsv, len);
|
||||
+ sv_setpvn(copysv, pv, len);
|
||||
+ SvPOK_off(copysv);
|
||||
+ }
|
||||
+ if (SvIOK(origsv) || SvIOKp(origsv))
|
||||
+ SvIV_set(copysv, SvIVX(origsv));
|
||||
+ if (SvNOK(origsv) || SvNOKp(origsv))
|
||||
+ SvNV_set(copysv, SvNVX(origsv));
|
||||
+ SvFLAGS(copysv) |= SvFLAGS(origsv) &
|
||||
+ (SVf_IOK|SVf_NOK|SVf_POK|SVp_IOK|SVp_NOK|SVp_POK|
|
||||
+ SVf_UTF8|SVf_IVisUV);
|
||||
+ } else
|
||||
+#endif
|
||||
+ {
|
||||
+ pv = SvPV_nomg(origsv, len);
|
||||
+ copysv = newSVpvn_flags(pv, len,
|
||||
+ (SvFLAGS(origsv) & SVf_UTF8) | SVs_TEMP);
|
||||
+ }
|
||||
+ *MARK = copysv;
|
||||
}
|
||||
MARK = ORIGMARK;
|
||||
|
||||
--
|
||||
2.13.6
|
||||
|
12
perl.spec
12
perl.spec
@ -245,6 +245,13 @@ Patch71: perl-5.26.1-set-when-statting-a-closed-filehandle.patch
|
||||
# in upstream after 5.27.5
|
||||
Patch72: perl-5.27.5-fix-tainting-of-s-with-overloaded-replacement.patch
|
||||
|
||||
# Expand system() arguments before a fork, RT#121105,
|
||||
# in upstream after 5.27.6
|
||||
Patch73: perl-5.26.1-perform-system-arg-processing-before-fork.patch
|
||||
# in upstream after 5.27.7
|
||||
Patch74: perl-5.27.7-preserve-numericness-of-system-args-on-Win32.patch
|
||||
Patch75: perl-5.27.7-Reenable-numeric-first-argument-of-system-on-VMS.patch
|
||||
|
||||
# Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048
|
||||
Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch
|
||||
|
||||
@ -2832,6 +2839,9 @@ Perl extension for Version Objects
|
||||
%patch70 -p1
|
||||
%patch71 -p1
|
||||
%patch72 -p1
|
||||
%patch73 -p1
|
||||
%patch74 -p1
|
||||
%patch75 -p1
|
||||
%patch200 -p1
|
||||
%patch201 -p1
|
||||
|
||||
@ -2878,6 +2888,7 @@ perl -x patchlevel.h \
|
||||
'Fedora Patch70: Fix stack manipulation when a lexical subroutine is defined in a do block in a member of an iteration list (RT#132442)' \
|
||||
'Fedora Patch71: Fix setting $! when statting a closed filehandle (RT#108288)' \
|
||||
'Fedora Patch72: Fix tainting of s/// with overloaded replacement (RT#115266)' \
|
||||
'Fedora Patch73: Expand system() arguments before a fork (RT#121105)' \
|
||||
'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \
|
||||
'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \
|
||||
%{nil}
|
||||
@ -5178,6 +5189,7 @@ popd
|
||||
a member of an iteration list (RT#132442)
|
||||
- Fix setting $! when statting a closed filehandle (RT#108288)
|
||||
- Fix tainting of s/// with overloaded replacement (RT#115266)
|
||||
- Expand system() arguments before a fork (RT#121105)
|
||||
|
||||
* Mon Sep 25 2017 Jitka Plesnikova <jplesnik@redhat.com> - 4:5.26.1-401
|
||||
- Update perl(:MODULE_COMPAT)
|
||||
|
Loading…
Reference in New Issue
Block a user