Fix a crash when compiling a malformed form

This commit is contained in:
Petr Písař 2019-01-15 08:53:49 +01:00
parent ca28c96764
commit 8cee2a9175
2 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,62 @@
From 817480137a8b1165315f21d14b8968862101c3a2 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Tue, 28 Aug 2018 14:11:10 +1000
Subject: [PATCH] (perl #132158) abort compilation if we see an error compiling
a form
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
t/lib/croak/toke | 9 +++++++++
toke.c | 9 +++++++++
2 files changed, 18 insertions(+)
diff --git a/t/lib/croak/toke b/t/lib/croak/toke
index 59c377ba6b..21851229fe 100644
--- a/t/lib/croak/toke
+++ b/t/lib/croak/toke
@@ -493,3 +493,12 @@ sub t1 {}
sub t2 (}
EXPECT
Prototype not terminated at - line 2.
+########
+# NAME [perl #132158] format with syntax errors
+format=
+@
+=h
+=cut
+EXPECT
+syntax error at - line 4, next token ???
+Execution of - aborted due to compilation errors.
diff --git a/toke.c b/toke.c
index 844de04a23..666424ba02 100644
--- a/toke.c
+++ b/toke.c
@@ -5099,6 +5099,14 @@ Perl_yylex(pTHX)
return yylex();
case LEX_FORMLINE:
+ if (PL_parser->sub_error_count != PL_error_count) {
+ /* There was an error parsing a formline, which tends to
+ mess up the parser.
+ Unlike interpolated sub-parsing, we can't treat any of
+ these as recoverable, so no need to check sub_no_recover.
+ */
+ yyquit();
+ }
assert(PL_lex_formbrack);
s = scan_formline(PL_bufptr);
if (!PL_lex_formbrack)
@@ -6518,6 +6526,7 @@ Perl_yylex(pTHX)
SAVEI32(PL_lex_formbrack);
PL_parser->form_lex_state = PL_lex_state;
PL_lex_formbrack = PL_lex_brackets + 1;
+ PL_parser->sub_error_count = PL_error_count;
goto leftbracket;
}
}
--
2.17.2

View File

@ -232,6 +232,9 @@ Patch44: perl-5.28.1-perl-133524-report-line-number-for-Prototype-not-ter
Patch45: perl-5.29.6-perl-133721-TODO-test-for-eof-with-no-LAST_FH.patch
Patch46: perl-5.29.6-First-eof-should-return-true.patch
# Fix a crash when compiling a malformed form, RT#132158, in upstream after 5.29.6
Patch47: perl-5.29.6-perl-132158-abort-compilation-if-we-see-an-error-com.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 +2835,7 @@ Perl extension for Version Objects
%patch44 -p1
%patch45 -p1
%patch46 -p1
%patch47 -p1
%patch200 -p1
%patch201 -p1
@ -2872,6 +2876,7 @@ perl -x patchlevel.h \
'Fedora Patch42: Do not close an IPC pipe that already has a desired descriptor (RT#133726)' \
'Fedora Patch44: Fix reporting a line number for non-terminated prototypes (RT#133524)' \
'Fedora Patch45: Fix first eof() return value (RT#133721)' \
'Fedora Patch47: Fix a crash when compiling a malformed form (RT#132158)' \
'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}
@ -5165,6 +5170,7 @@ popd
- Do not close an IPC pipe that already has a desired descriptor (RT#133726)
- Fix reporting a line number for non-terminated prototypes (RT#133524)
- Fix first eof() return value (RT#133721)
- Fix a crash when compiling a malformed form (RT#132158)
* Mon Jan 14 2019 Björn Esser <besser82@fedoraproject.org> - 4:5.28.1-429
- Rebuilt for libcrypt.so.2 (#1666033)