Fix parsing perl options in shell bang line
This commit is contained in:
parent
20d4f3847b
commit
dee7e92b27
|
@ -0,0 +1,92 @@
|
||||||
|
From 03fcc0c44bc7972f2c92736daae5b63d601b7c49 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Dan Collins <dcollinsn@gmail.com>
|
||||||
|
Date: Fri, 23 Sep 2016 01:21:20 -0400
|
||||||
|
Subject: [PATCH] [rt #129336] #!perl -i u erroneously interpreted as -u
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Ported to 5.24.0:
|
||||||
|
|
||||||
|
commit f54cfdacff1f3744ef08fc70f1f3bc6c7d862e83
|
||||||
|
Author: Dan Collins <dcollinsn@gmail.com>
|
||||||
|
Date: Fri Sep 23 01:21:20 2016 -0400
|
||||||
|
|
||||||
|
[rt #129336] #!perl -i u erroneously interpreted as -u
|
||||||
|
|
||||||
|
Perl_moreswitches processes a single switch, and returns a pointer
|
||||||
|
to the start of the next switch. It can return either
|
||||||
|
the a pointer to the next flag itself:
|
||||||
|
|
||||||
|
#!perl -n -p
|
||||||
|
^ Can point here
|
||||||
|
|
||||||
|
Or, to the space before the next "arg":
|
||||||
|
|
||||||
|
#!perl -n -p
|
||||||
|
^ Can point here
|
||||||
|
|
||||||
|
(Where the next call to Perl_moreswitches will consume " -".)
|
||||||
|
|
||||||
|
In the case of -i[extension], the pointer is by default pointing at
|
||||||
|
the space after the end of the argument. The current code tries to
|
||||||
|
do the former, by unconditionally advancing the pointer, and then
|
||||||
|
advancing it again if it is on a '-'. But that is incorrect:
|
||||||
|
|
||||||
|
#!perl -i p
|
||||||
|
^ Will point here, but that isn't a flag
|
||||||
|
|
||||||
|
I could fix this by removing the unconditional s++, and having it
|
||||||
|
increment by 2 if *(s+1)=='-', but this work isn't actually
|
||||||
|
necessary - it's better to just leave it pointing at the space after
|
||||||
|
the argument.
|
||||||
|
|
||||||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||||
|
---
|
||||||
|
perl.c | 5 -----
|
||||||
|
t/op/lex.t | 9 ++++++++-
|
||||||
|
2 files changed, 8 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/perl.c b/perl.c
|
||||||
|
index 228a0d8..5cc7d0b 100644
|
||||||
|
--- a/perl.c
|
||||||
|
+++ b/perl.c
|
||||||
|
@@ -3306,11 +3306,6 @@ Perl_moreswitches(pTHX_ const char *s)
|
||||||
|
|
||||||
|
PL_inplace = savepvn(start, s - start);
|
||||||
|
}
|
||||||
|
- if (*s) {
|
||||||
|
- ++s;
|
||||||
|
- if (*s == '-') /* Additional switches on #! line. */
|
||||||
|
- s++;
|
||||||
|
- }
|
||||||
|
return s;
|
||||||
|
case 'I': /* -I handled both here and in parse_body() */
|
||||||
|
forbid_setid('I', FALSE);
|
||||||
|
diff --git a/t/op/lex.t b/t/op/lex.t
|
||||||
|
index c515449..9ada592 100644
|
||||||
|
--- a/t/op/lex.t
|
||||||
|
+++ b/t/op/lex.t
|
||||||
|
@@ -7,7 +7,7 @@ use warnings;
|
||||||
|
|
||||||
|
BEGIN { chdir 't' if -d 't'; require './test.pl'; }
|
||||||
|
|
||||||
|
-plan(tests => 25);
|
||||||
|
+plan(tests => 26);
|
||||||
|
|
||||||
|
{
|
||||||
|
no warnings 'deprecated';
|
||||||
|
@@ -209,3 +209,10 @@ fresh_perl_is(
|
||||||
|
{ stderr => 1 },
|
||||||
|
's;@{<<a; [perl #123995]'
|
||||||
|
);
|
||||||
|
+
|
||||||
|
+fresh_perl_like(
|
||||||
|
+ "#!perl -i u\nprint 'OK'",
|
||||||
|
+ qr/OK/,
|
||||||
|
+ {},
|
||||||
|
+ '[perl #129336] - #!perl -i argument handling'
|
||||||
|
+);
|
||||||
|
--
|
||||||
|
2.7.4
|
||||||
|
|
|
@ -203,6 +203,9 @@ Patch53: perl-5.25.4-perl-129267-Test-for-gv_fetchmethod-buffer-overrun.p
|
||||||
# in upstream after 5.25.5
|
# in upstream after 5.25.5
|
||||||
Patch54: perl-5.24.0-perl-129350-anchored-floating-substrings-must-be-utf.patch
|
Patch54: perl-5.24.0-perl-129350-anchored-floating-substrings-must-be-utf.patch
|
||||||
|
|
||||||
|
# Fix parsing perl options in shell bang line, RT#129336,
|
||||||
|
# in upstream after 5.25.5
|
||||||
|
Patch55: perl-5.24.0-rt-129336-perl-i-u-erroneously-interpreted-as-u.patch
|
||||||
# Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048
|
# 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
|
Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch
|
||||||
|
|
||||||
|
@ -2880,6 +2883,7 @@ Perl extension for Version Objects
|
||||||
%patch52 -p1
|
%patch52 -p1
|
||||||
%patch53 -p1
|
%patch53 -p1
|
||||||
%patch54 -p1
|
%patch54 -p1
|
||||||
|
%patch55 -p1
|
||||||
%patch200 -p1
|
%patch200 -p1
|
||||||
%patch201 -p1
|
%patch201 -p1
|
||||||
|
|
||||||
|
@ -2925,6 +2929,7 @@ perl -x patchlevel.h \
|
||||||
'Fedora Patch52: Fix string overrun in Perl_gv_fetchmethod_pvn_flags (RT#129267)' \
|
'Fedora Patch52: Fix string overrun in Perl_gv_fetchmethod_pvn_flags (RT#129267)' \
|
||||||
'Fedora Patch53: Fix string overrun in Perl_gv_fetchmethod_pvn_flags (RT#129267)' \
|
'Fedora Patch53: Fix string overrun in Perl_gv_fetchmethod_pvn_flags (RT#129267)' \
|
||||||
'Fedora Patch54: Fix crash when matching UTF-8 string with non-UTF-8 substrings (RT#129350)' \
|
'Fedora Patch54: Fix crash when matching UTF-8 string with non-UTF-8 substrings (RT#129350)' \
|
||||||
|
'Fedora Patch55: Fix parsing perl options in shell bang line (RT#129336)' \
|
||||||
'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \
|
'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' \
|
'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \
|
||||||
%{nil}
|
%{nil}
|
||||||
|
@ -5208,6 +5213,7 @@ popd
|
||||||
- Fix crash in splice (RT#129164, RT#129166, RT#129167)
|
- Fix crash in splice (RT#129164, RT#129166, RT#129167)
|
||||||
- Fix string overrun in Perl_gv_fetchmethod_pvn_flags (RT#129267)
|
- Fix string overrun in Perl_gv_fetchmethod_pvn_flags (RT#129267)
|
||||||
- Fix crash when matching UTF-8 string with non-UTF-8 substrings (RT#129350)
|
- Fix crash when matching UTF-8 string with non-UTF-8 substrings (RT#129350)
|
||||||
|
- Fix parsing perl options in shell bang line (RT#129336)
|
||||||
|
|
||||||
* Fri Sep 02 2016 Petr Pisar <ppisar@redhat.com> - 4:5.24.0-378
|
* Fri Sep 02 2016 Petr Pisar <ppisar@redhat.com> - 4:5.24.0-378
|
||||||
- perl-core depends on Parse::CPAN::Meta module instead of package name to allow
|
- perl-core depends on Parse::CPAN::Meta module instead of package name to allow
|
||||||
|
|
Loading…
Reference in New Issue