Debian Codegraph @

debian/patches/80-Fix-STRLEN-vs-int-pointer-confusion-in-Tcl_GetByteAr.patch

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