perl: apply patch for CVE-2024-56406

This commit is contained in:
Stig Palmquist 2025-04-11 11:49:51 +02:00
parent ab12ae909b
commit 821d2fe81d
No known key found for this signature in database
2 changed files with 29 additions and 1 deletions

View File

@ -0,0 +1,26 @@
commit 385e8759c3ff1e7f7f996bd4ea391074d61d48c1
Author: Karl Williamson <khw@cpan.org>
AuthorDate: 2024-12-18 18:25:29 -0700
Commit: Steve Hay <steve.m.hay@googlemail.com>
CommitDate: 2025-03-30 11:59:51 +0100
CVE-2024-56406: Heap-buffer-overflow with tr//
This was due to underallocating needed space. If the translation forces
something to become UTF-8 that is initially bytes, that UTF-8 could
now require two bytes where previously a single one would do.
(cherry picked from commit f93109c8a6950aafbd7488d98e112552033a3686)
diff --git a/op.c b/op.c
index 3fc23eca49a..aeee88e0335 100644
--- a/op.c
+++ b/op.c
@@ -6649,6 +6649,7 @@ S_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
* same time. But otherwise one crosses before the other */
if (t_cp < 256 && r_cp_end > 255 && r_cp != t_cp) {
can_force_utf8 = TRUE;
+ max_expansion = MAX(2, max_expansion);
}
}

View File

@ -71,7 +71,9 @@ stdenv.mkDerivation (
disallowedReferences = [ stdenv.cc ];
patches =
[ ]
[
./CVE-2024-56406.patch
]
# Do not look in /usr etc. for dependencies.
++ lib.optional ((lib.versions.majorMinor version) == "5.38") ./no-sys-dirs-5.38.0.patch
++ lib.optional ((lib.versions.majorMinor version) == "5.40") ./no-sys-dirs-5.40.0.patch