[Rt-commit] rt branch, 4.0/raw-mode-on-scalar-ref, created. rt-4.0.8-281-g705eac4

Alex Vandiver alexmv at bestpractical.com
Wed Dec 19 19:50:04 EST 2012


The branch, 4.0/raw-mode-on-scalar-ref has been created
        at  705eac40204563c527e7a32e51daa9d8620a0f49 (commit)

- Log -----------------------------------------------------------------
commit 705eac40204563c527e7a32e51daa9d8620a0f49
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Dec 19 19:45:30 2012 -0500

    Work around a bug in perl < 5.13.10 with open($fh, ">:raw", \$string)
    
    Perl version 5.13.9 and earlier had poor interactions with :raw and the
    PerlIO layers which redirect output into in-memory strings; these caused
    open($fh, ">:raw", \$string) to create a file on disk named
    "SCALAR(0xDEADBEEF)" on such versions of perl.
    
    Change the two callsites which open in ">:raw" mode into an in-memory
    string to using the ">" mode and then calling binmode($fh, ":raw"),
    which works around this bug.

diff --git a/lib/RT/Crypt/GnuPG.pm b/lib/RT/Crypt/GnuPG.pm
index 784ba0e..2552994 100644
--- a/lib/RT/Crypt/GnuPG.pm
+++ b/lib/RT/Crypt/GnuPG.pm
@@ -910,13 +910,15 @@ sub FindProtectedParts {
                 local $@;
                 eval {
                     my $buf = '';
-                    open my $fh, '>:raw', \$buf
+                    open my $fh, '>', \$buf
                         or die "Couldn't open scalar for writing: $!";
+                    binmode $fh, ":raw";
                     $decoder->decode($io, $fh);
                     close $fh or die "Couldn't close scalar: $!";
 
-                    open $fh, '<:raw', \$buf
+                    open $fh, '<', \$buf
                         or die "Couldn't re-open scalar for reading: $!";
+                    binmode $fh, ":raw";
                     $io = $fh;
                     1;
                 } or do {

-----------------------------------------------------------------------


More information about the Rt-commit mailing list