Skip Menu |

This queue is for tickets about the Digest-SHA CPAN distribution.

Report information
The Basics
Id: 34690
Status: resolved
Worked: 2 hours (120 min)
Priority: 0/
Queue: Digest-SHA

People
Owner: mshelor [...] cpan.org
Requestors: brock [...] kuhsefamily.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 5.45
Fixed in: 5.46



Subject: Digest::SHA errors with trailing space in file name
Date: Fri, 4 Apr 2008 15:38:33 -0700
To: <bug-Digest-SHA [...] rt.cpan.org>
From: "Brock Kuhse" <brock [...] kuhsefamily.org>
Digest::SHA version 5.45 with perl 5.8.8 on Fedora 8 When the file name used by the addfile method has a trailing space, it fails with "Open failed: No such file or directory". The problem appears to be in the Addfile subroutine of SHA.pm. If the open command is changed to a "three argument" string, it seems to work. I used: open FH, "<", $file or _bail("Open failed"); instead of: open(FH,"<$file") or _bail("Open failed"); Patch attached. - Brock

Message body is not shown because sender requested not to inline it.

RT-Send-CC: brock [...] kuhsefamily.org
Yes, Perl's 2-arg "open" ignores leading and trailing whitespace in filenames. The next version of Digest::SHA, scheduled for release later this month, will remedy the problem. However, the suggested patch will not be used. The 3-arg version of "open" has two serious flaws in the context of Digest::SHA: 1. It is not portable to versions of Perl prior to 5.6, and would orphan the large number of Digest::SHA users who operate on legacy platforms running ancient Perls. 2. It has no magic, and interprets "-" as a literal filename instead of STDIN, thereby breaking the "shasum" script as well as existing user applications that rely on open's magic. So, the 2-arg "open" will be retained, and something like the following will be done to protect any leading or trailing whitespace (ref. perldoc -f open): $file =~ s#^(\s)#./$1#; open(FOO, "< $file\0"); Mark
Subject: RE: [rt.cpan.org #34690] Digest::SHA errors with trailing space in file name
Date: Sun, 6 Apr 2008 08:05:24 -0700
To: <bug-Digest-SHA [...] rt.cpan.org>
From: "Brock Kuhse" <brock [...] kuhsefamily.org>
Show quoted text
> -----Original Message----- > From: Mark Shelor via RT [mailto:bug-Digest-SHA@rt.cpan.org] > Sent: Sunday, April 06, 2008 3:50 AM > To: brock@kuhsefamily.org > Subject: [rt.cpan.org #34690] Digest::SHA errors with trailing space in > file name > > > <URL: http://rt.cpan.org/Ticket/Display.html?id=34690 > > > Yes, Perl's 2-arg "open" ignores leading and trailing whitespace in > filenames. The next version of Digest::SHA, scheduled for release > later this month, will remedy the problem. > > However, the suggested patch will not be used. The 3-arg version of > "open" has two serious flaws in the context of Digest::SHA: > > 1. It is not portable to versions of Perl prior to 5.6, and would > orphan > the large number of Digest::SHA users who operate on legacy platforms > running ancient Perls.
I've only been writing perl scripts for about 4 years, and didn't know. Good information. We make it a point to keep our Linux servers homogeneous and up to date (thanks to package managers and our own custom repo), but I know not everyone has the luxury. Show quoted text
> 2. It has no magic, and interprets "-" as a literal filename instead of > STDIN, thereby breaking the "shasum" script as well as existing user > applications that rely on open's magic.
I can see where that could be problematic. Show quoted text
> So, the 2-arg "open" will be retained, and something like the following > will be done to protect any leading or trailing whitespace (ref. > perldoc -f open): > > $file =~ s#^(\s)#./$1#; > open(FOO, "< $file\0");
Sounds good. My simple patch will get our Linux boxes through until the next release of Digest::SHA, at least. Thanks for the information, and for your work on this project - we use it to index and identify large numbers of files in backup volumes so our backup script can hard-link identical files that have had their names or paths changed since the last backup. Integrating Digest::SHA it into our backup script was trivial, so, thanks again. Why our clients (and/or their software vendors) feel compelled to save files with trailing white spaces is beyond me... - Brock
RT-Send-CC: brock [...] kuhsefamily.org
As of version 5.46, Digest::SHA treats leading and trailing whitespace in filenames as significant. This applies to version 5.46 of Digest::SHA::PurePerl as well.