Improve retrieving a scalar value of a variable modified in a signal handler

This commit is contained in:
Petr Písař 2019-06-25 16:43:32 +02:00
parent 28b3f8c52b
commit e7d6451704
2 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,42 @@
From 368ac47cccd4ffca6e83a26289c152a32c2ea385 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Wed, 17 Apr 2019 15:45:15 +1000
Subject: [PATCH] (perl #134035) ensure sv_gets() handles a signal handler
modifying sv
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
At a very basic level at least.
In the ticket cases, a signal handler is modifying (and reallocating
PVX) the sv, while sv_gets() retained a pointer to the inside of the
SV.
This still has some problems, like if the signal handler ends up
shortening SV, there may be old data left between the old position
and the new position, but I think that's a case of user error.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
sv.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sv.c b/sv.c
index 8bc0af0c16..83de536ad7 100644
--- a/sv.c
+++ b/sv.c
@@ -8755,7 +8755,10 @@ Perl_sv_gets(pTHX_ SV *const sv, PerlIO *const fp, I32 append)
Note we have to deal with the char in 'i' if we are not at EOF
*/
+ bpx = bp - (STDCHAR*)SvPVX_const(sv);
+ /* signals might be called here, possibly modifying sv */
i = PerlIO_getc(fp); /* get more characters */
+ bp = (STDCHAR*)SvPVX_const(sv) + bpx;
DEBUG_Pv(PerlIO_printf(Perl_debug_log,
"Screamer: post: FILE * thinks ptr=%" UVuf ", cnt=%" IVdf ", base=%" UVuf "\n",
--
2.20.1

View File

@ -187,6 +187,10 @@ Patch27: perl-5.31.0-perl-133913-limit-numeric-format-results-to-INT_MAX.
# fixed after 5.31.0
Patch28: perl-5.31.0-perl-134072-allow-foo-bar-to-work-in-main.patch
# Improve retrieving a scalar value of a variable modified in a signal
# handler, RT#134035, fixed after 5.31.0
Patch29: perl-5.31.0-perl-134035-ensure-sv_gets-handles-a-signal-handler-.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
@ -2733,6 +2737,7 @@ Perl extension for Version Objects
%patch26 -p1
%patch27 -p1
%patch28 -p1
%patch29 -p1
%patch200 -p1
%patch201 -p1
@ -2768,6 +2773,7 @@ perl -x patchlevel.h \
'Fedora Patch26: Fix an erroneous assertion on OP_SCALAR (RT#134048)' \
'Fedora Patch27: Prevent from wrapping a width in a numeric format string (RT#133913)' \
'Fedora Patch28: Fix subroutine protypes to track reference aliases (RT#134072)' \
'Fedora Patch29: Improve retrieving a scalar value of a variable modified in a signal handler (RT#134035)' \
'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}
@ -5025,6 +5031,8 @@ popd
- Fix an erroneous assertion on OP_SCALAR (RT#134048)
- Prevent from wrapping a width in a numeric format string (RT#133913)
- Fix subroutine protypes to track reference aliases (RT#134072)
- Improve retrieving a scalar value of a variable modified in a signal handler
(RT#134035)
* Tue Jun 11 2019 Jitka Plesnikova <jplesnik@redhat.com> - 4:5.30.0-439
- Define %%perl_vendor*, %%perl_archlib, %%perl_privlib, because in rpm