| 1 | https://bugs.gentoo.org/916814
|
| 2 | https://salsa.debian.org/georgesk/perl-tk/-/blob/master/debian/patches/80-Fix-STRLEN-vs-int-pointer-confusion-in-Tcl_GetByteAr.patch?ref_type=heads
|
| 3 |
|
| 4 | From a26233c844c52f49ef9cca5f88dd9063aac60d0f Mon Sep 17 00:00:00 2001
|
| 5 | From: Niko Tyni <[email protected]>
|
| 6 | Date: Thu, 11 Jan 2024 18:28:58 +0000
|
| 7 | Subject: [PATCH] Fix STRLEN vs int pointer confusion in
|
| 8 | Tcl_GetByteArrayFromObj()
|
| 9 |
|
| 10 | Perl 5.37.2, more precisely commit
|
| 11 |
|
| 12 | https://github.com/Perl/perl5/commit/1ef9039bccbfe64f47f201b6cfb7d6d23e0b08a7
|
| 13 |
|
| 14 | changed the implementation of SvPV() et al., breaking t/balloon.t,
|
| 15 | t/canvas2.t and t/photo.t on big-endian 64-bit architectures such as
|
| 16 | ppc64 and s390x because StringMatchGIF() no longer recognized GIF files.
|
| 17 |
|
| 18 | This is because Tcl_GetByteArrayFromObj() was calling SvPV() with an int
|
| 19 | pointer instead of a correct STRLEN pointer, and the new implementation
|
| 20 | is more sensitive to this: it assigns the pointers as-is, resulting in
|
| 21 | the int pointer pointing at the wrong end of the 64-bit length.
|
| 22 |
|
| 23 | Other functions taking a length pointer, at least Tcl_GetStringFromObj()
|
| 24 | already seem to do things correctly, so presumably this is not a
|
| 25 | systematic issue.
|
| 26 | ---
|
| 27 | objGlue.c | 5 ++++-
|
| 28 | 1 file changed, 4 insertions(+), 1 deletion(-)
|
| 29 |
|
| 30 | diff --git a/objGlue.c b/objGlue.c
|
| 31 | index d4927ea..dbd6a50 100644
|
| 32 | |
| 33 | |
| 34 | @@ -627,7 +627,10 @@ Tcl_GetByteArrayFromObj(Tcl_Obj * objPtr, int * lengthPtr)
|
| 35 | sv_utf8_downgrade(objPtr, 0);
|
| 36 | if (lengthPtr)
|
| 37 | {
|
| 38 | - return (unsigned char *) SvPV(objPtr, *lengthPtr);
|
| 39 | + STRLEN len;
|
| 40 | + unsigned char *s = SvPV(objPtr, len);
|
| 41 | + *lengthPtr = len;
|
| 42 | + return s;
|
| 43 | }
|
| 44 | else
|
| 45 | {
|
| 46 | --
|
| 47 | 2.30.2
|
| 48 |
|