main/perl: backport 2 patches

from Debian:

  - json-pp-options.patch fixes `Duplicate
    specification "V" for option "v"` warning
    when running /usr/bin/json_pp from the
    perl-utils subpackage

  - strftime-fmt.patch fixes `Out of memory in
    perl:util:safesysmalloc` error that causes
    perl-tickit-console test to fail on 64-bit
This commit is contained in:
Celeste 2024-09-01 14:35:31 +00:00
parent 9e80251dca
commit feefafaf98
3 changed files with 112 additions and 1 deletions

View file

@ -4,7 +4,7 @@
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=perl
pkgver=5.40.0
pkgrel=1
pkgrel=2
pkgdesc="Larry Wall's Practical Extraction and Report Language"
url="https://www.perl.org/"
arch="all"
@ -15,9 +15,11 @@ subpackages="$pkgname-doc $pkgname-dev $pkgname-utils::noarch miniperl"
source="https://www.cpan.org/src/5.0/perl-$pkgver.tar.xz
digest-sha-cflags.patch
dont-write-packlist.patch
json-pp-options.patch
musl-skip-dst-test.patch
musl-stack-size.patch
skip-test-due-to-busybox-ps.patch
strftime-fmt.patch
"
# creates empty usr/local/{lib,share} for local sitedirs
options="!fhs"
@ -195,7 +197,9 @@ sha512sums="
a2fb1a24c6367b4043f4e929b2d74fc3bad1415e53b791ed1f219f1701064ae21b2bd3164ba95fcf24eaf458bd54433024ccae43725c0bb82a1ec6a98dc7052d perl-5.40.0.tar.xz
59afa4c166e4808d355e19cd70748540ffce9da5c6919c71648be7678de328409f9121ddea33415add73fc01a22e95ed9d9629f31b8ba20b3bbfc04dab926c63 digest-sha-cflags.patch
abae709290306a8fbc96b604b9b38fc09a46ae178f3e77944813f1b46c78e2e3654e5c3b3a6aca96684a2d1061e2871376d508fbe82604864055309156b4d0d8 dont-write-packlist.patch
4e8a655160e54a151e0bc4819fd1cd69e43c1e36844bcefbb9734f36130a2d9e1700b1aa64153a9d20a8deb875e904876dbe7b14dd278266b21a86a33d91eebd json-pp-options.patch
3eaec691bc38e208ba4f34130ae45e50b6c339fa50093d0b0f6d7f24cb5b7c2a3734ca714a279c4b51173f82e46a8e7a3e70bfc7d7471a18c55a2102140e4186 musl-skip-dst-test.patch
c004d6612ec754e5947255a2e2d15b5581f187c32495aeeec9f4fa286919bd9f40c72b63db61e3f4004b09288af2063a6a14b67e5c289e9a8b23ebd7c216e16f musl-stack-size.patch
ba9cb1ff4a6e8e4c31bf4ef132c071ac919ffe45842cf5e98c8ca72d78ef4803883b57a0e7b8037da0079561a6ce9e6bd8d127892ac1bcb047638cb3ba3157f6 skip-test-due-to-busybox-ps.patch
df9cbb50326beecc49f5a59af267e02965bee5d56b852edcb0d2ab57689d080fedb2ddad110d05b97215c999a51573d540e8a8a8bbd94a39b5464d9bdedc51de strftime-fmt.patch
"

View file

@ -0,0 +1,29 @@
Patch-Source: https://salsa.debian.org/perl-team/interpreter/perl/-/raw/debian/5.40.0-3/debian/patches/fixes/json-pp-options.diff
--
From: Niko Tyni <ntyni@debian.org>
Date: Wed, 7 Aug 2024 22:53:54 +0300
Subject: Fix json_pp option handling
Getopt-Long ignores case by default, so -v never worked.
Getopt-Long 2.55 / Perl 5.40 started to warn about this.
Bug: https://github.com/makamaka/JSON-PP/issues/88
Bug-Debian: https://bugs.debian.org/1078058
---
cpan/JSON-PP/bin/json_pp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cpan/JSON-PP/bin/json_pp b/cpan/JSON-PP/bin/json_pp
index 72b9db7..85dd348 100644
--- a/cpan/JSON-PP/bin/json_pp
+++ b/cpan/JSON-PP/bin/json_pp
@@ -2,7 +2,7 @@
BEGIN { pop @INC if $INC[-1] eq '.' }
use strict;
-use Getopt::Long;
+use Getopt::Long qw( :config no_ignore_case );
use Encode ();
use JSON::PP ();

View file

@ -0,0 +1,78 @@
Patch-Source: https://salsa.debian.org/perl-team/interpreter/perl/-/raw/debian/5.40.0-3/debian/patches/fixes/strftime-fmt.diff
--
From: Lukas Mai <lukasmai.403@gmail.com>
Date: Sun, 11 Aug 2024 08:25:03 +0200
Subject: locale: stringify strftime fmt before querying length/utf8ness
POSIX::strftime() can call sv_strftime_common() with arbitrary SVs.
SvCUR() assumes it is being called on an actual string. With other SV
types it can return garbage or just crash.
Make sure SvPV() is called first to stringify the format, before
SvUTF8() and SvCUR() inspect the SV.
Fixes #22498.
[Trivially backported to 5.40.0 by Niko Tyni <ntyni@debian.org>]
Origin: backport, https://github.com/Perl/perl5/commit/3e14b2fcf59b5b88b289caa973f0b8748c93a594
Bug: https://github.com/Perl/perl5/issues/22498
Bug-Debian: https://bugs.debian.org/1078152
---
ext/POSIX/t/time.t | 13 ++++++++++++-
locale.c | 7 +++++--
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/ext/POSIX/t/time.t b/ext/POSIX/t/time.t
index 44cba60..6878ed4 100644
--- a/ext/POSIX/t/time.t
+++ b/ext/POSIX/t/time.t
@@ -9,7 +9,7 @@ use strict;
use Config;
use POSIX;
-use Test::More tests => 26;
+use Test::More tests => 30;
# For the first go to UTC to avoid DST issues around the world when testing. SUS3 says that
# null should get you UTC, but some environments want the explicit names.
@@ -205,3 +205,14 @@ SKIP: {
is(mktime(CORE::localtime($time)), $time, "mktime()");
is(mktime(POSIX::localtime($time)), $time, "mktime()");
}
+
+{
+ # GH #22498
+ is(strftime(42, CORE::localtime), '42', "strftime() works if format is a number");
+ my $obj = bless {}, 'Some::Random::Class';
+ is(strftime($obj, CORE::localtime), "$obj", "strftime() works if format is an object");
+ my $warnings = '';
+ local $SIG{__WARN__} = sub { $warnings .= $_[0] };
+ is(strftime(undef, CORE::localtime), '', "strftime() works if format is undef");
+ like($warnings, qr/^Use of uninitialized value in subroutine entry /, "strftime(undef, ...) produces expected warning");
+}
diff --git a/locale.c b/locale.c
index 6f4853c..e3874ec 100644
--- a/locale.c
+++ b/locale.c
@@ -8178,6 +8178,9 @@ S_sv_strftime_common(pTHX_ SV * fmt,
{ /* Documented above */
PERL_ARGS_ASSERT_SV_STRFTIME_COMMON;
+ STRLEN fmt_cur;
+ const char *fmt_str = SvPV_const(fmt, fmt_cur);
+
utf8ness_t fmt_utf8ness = (SvUTF8(fmt) && LIKELY(! IN_BYTES))
? UTF8NESS_YES
: UTF8NESS_UNKNOWN;
@@ -8188,8 +8191,8 @@ S_sv_strftime_common(pTHX_ SV * fmt,
* to get almost all the typical returns to fit without the called function
* having to realloc; this is a somewhat educated guess, but feel free to
* tweak it. */
- SV* sv = newSV(MAX(SvCUR(fmt) * 2, 64));
- if (! strftime8(SvPV_nolen(fmt),
+ SV* sv = newSV(MAX(fmt_cur * 2, 64));
+ if (! strftime8(fmt_str,
sv,
locale,
mytm,