Subject: | \r handled badly by Module::Signature |
Date: | Mon, 25 May 2009 08:39:10 +0100 |
To: | bug-Module-Signature [...] rt.cpan.org |
From: | Zefram <zefram [...] fysh.org> |
Module::Signature attempts to canonicalise line endings in text files in
order to get a representation-independent SHA1 value for the SIGNATURE
file. There are a couple of problems with this.
Firstly, it's giving different results on different perl versions.
It appears, from my tests, that the ":crlf" layer doesn't do anything
on 5.6, whereas on 5.8+ it turns "\r\n" into "\n". So a file that uses
CRs gets a different SHA1 value depending on the perl version, causing
false signature verification errors. I've run into this with two separate
modules that have "\r\n" line endings in some of the files as distributed.
I'm working around this by avoiding using CRs in distribution packages,
but M::S really needs to use a different strategy on 5.6 to validate
the existing signatures.
Second, more fundamentally, the canonicalisation is a stupid thing to do.
The difference between "\r\n" and "\n" can be significant. One of
the places I've had trouble is a file of test data in XML::Easy, which
needs to test the parser against the three major types of line ending.
The type of ending to each line is very important in that file, and the
SHA1 value in the SIGNATURE file describes a broken version of the file.
More trivially, the text-mode canonicalisation will screw up on binaries.
(The XML test data file, while notionally textual, is probably best
treated as a binary, in fact.)
By SHA1ing something other than the actual distributed file, you've
opened up room for security holes.
-zefram