Skip Menu |

This queue is for tickets about the PerlIO-via-CBC CPAN distribution.

Report information
The Basics
Id: 40208
Status: new
Priority: 0/
Queue: PerlIO-via-CBC

People
Owner: Nobody in particular
Requestors: ericparusel [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Problem with linefeeds in the salt and FILL()
Date: Mon, 20 Oct 2008 16:07:18 -0700
To: bug-PerlIO-via-CBC [...] rt.cpan.org
From: "Eric Parusel" <ericparusel [...] gmail.com>
Hi, I'm using PerlIO::via::CBC v0.0.8 on Perl 5.8.8 on Solaris x86 and it was working quite well, until I came across an encrypted file that had a linefeed in the salt. I open the file with :via(PerlIO::via::CBC), and then do a while (<fh>) {}. When there's a linefeed in the salt, the first "chunk" of data returned to FILL() is only 11 bytes long, and Crypt::CBC dies because the data chunk does not start with "/^Salted__.{8}/", which is a 16 character string. It appears that the best way to solve this is to buffer the initial input until at least 16 characters has been received. Here is a patch that seems to work, but I'm unsure whether it's properly implemented in a few ways: - Should I be providing a FLUSH method? - Am I sanely using the object in that there's now both $self->[3] and $self->[4]? - Should I be using PerlIO::via::CBC in some different way to avoid this issue? Thanks, Eric --- /opt/csw/share/perl/site_perl/PerlIO/via/CBC.pm Wed Aug 2 15:11:55 2006 +++ /home/eparusel/CBC.pm Mon Oct 20 16:03:00 2008 @@ -35,7 +35,7 @@ $cbc->start('encrypting'); } - return (bless [$cbc, '', $_[1]], $_[0]); + return (bless [$cbc, '', $_[1], 0, ''], $_[0]); } sub FILL { @@ -48,7 +48,16 @@ # If there is something to be crypted, crypt it if(defined $line) { - return ($cbc->crypt($line)); + if ($self->[3]) { + return ($cbc->crypt($line)); + } else { + $self->[4] .= $line; + if (length($self->[4]) >= 16) { + $self->[3] = 1; + return $cbc->crypt($self->[4]); + } + return ''; + } # elsif we still have an object (and end of data reached) # Remove the object from PerlIO::via::Crypt object (so we'll really exit next)