r65804 - in /branches/upstream/libdigest-sha-perl/current: Changes META.yml README lib/Digest/SHA.pm shasum src/hmac.c src/hmac.h src/sha.c src/sha.h
carnil at users.alioth.debian.org
carnil at users.alioth.debian.org
Mon Dec 13 11:20:51 UTC 2010
Author: carnil
Date: Mon Dec 13 11:20:42 2010
New Revision: 65804
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=65804
Log:
[svn-upgrade] new version libdigest-sha-perl (5.49)
Modified:
branches/upstream/libdigest-sha-perl/current/Changes
branches/upstream/libdigest-sha-perl/current/META.yml
branches/upstream/libdigest-sha-perl/current/README
branches/upstream/libdigest-sha-perl/current/lib/Digest/SHA.pm
branches/upstream/libdigest-sha-perl/current/shasum
branches/upstream/libdigest-sha-perl/current/src/hmac.c
branches/upstream/libdigest-sha-perl/current/src/hmac.h
branches/upstream/libdigest-sha-perl/current/src/sha.c
branches/upstream/libdigest-sha-perl/current/src/sha.h
Modified: branches/upstream/libdigest-sha-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/Changes?rev=65804&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/Changes (original)
+++ branches/upstream/libdigest-sha-perl/current/Changes Mon Dec 13 11:20:42 2010
@@ -1,4 +1,13 @@
Revision history for Perl extension Digest::SHA.
+
+5.49 Sun Dec 12 07:22:04 MST 2010
+ - modified Addfile to accept all POSIX filenames
+ -- standard allows all characters except NUL and '/'
+ - updated shasum to more closely mimic sha1sum/md5sum
+ -- added "backslash processing" to handle newlines
+ and backslashes in filenames
+ -- now accepts all POSIX filenames via Addfile
+ -- thanks to Sean Burke for identifying edge cases
5.48 Mon Jan 4 16:32:52 MST 2010
- fixed "shasum -a0" option (ref. rt.cpan.org #53319)
Modified: branches/upstream/libdigest-sha-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/META.yml?rev=65804&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/META.yml (original)
+++ branches/upstream/libdigest-sha-perl/current/META.yml Mon Dec 13 11:20:42 2010
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Digest-SHA
-version: 5.48
+version: 5.49
abstract: Perl extension for SHA-1/224/256/384/512
license: perl
author:
@@ -10,7 +10,7 @@
provides:
Digest::SHA:
file: lib/Digest/SHA.pm
- version: 5.48
+ version: 5.49
meta-spec:
version: 1.3
url: http://module-build.sourceforge.net/META-spec-v1.3.html
Modified: branches/upstream/libdigest-sha-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/README?rev=65804&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/README (original)
+++ branches/upstream/libdigest-sha-perl/current/README Mon Dec 13 11:20:42 2010
@@ -1,4 +1,4 @@
-Digest::SHA version 5.48
+Digest::SHA version 5.49
========================
Digest::SHA is a complete implementation of the NIST Secure Hash
Modified: branches/upstream/libdigest-sha-perl/current/lib/Digest/SHA.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/lib/Digest/SHA.pm?rev=65804&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/lib/Digest/SHA.pm (original)
+++ branches/upstream/libdigest-sha-perl/current/lib/Digest/SHA.pm Mon Dec 13 11:20:42 2010
@@ -3,10 +3,11 @@
require 5.003000;
use strict;
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
+use Fcntl;
use integer;
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
-
-$VERSION = '5.48';
+
+$VERSION = '5.49';
require Exporter;
require DynaLoader;
@@ -113,11 +114,14 @@
my ($binary, $portable) = map { $_ eq $mode } ("b", "p");
my $text = -T $file;
+ ## Use sysopen to accommodate full range of POSIX
+ ## file names; fall back to open for magic (-)
local *FH;
- # protect any leading or trailing whitespace in $file;
- # otherwise, 2-arg "open" will ignore them
- $file =~ s#^(\s)#./$1#;
- open(FH, "< $file\0") or _bail("Open failed");
+ unless (sysopen(FH, $file, O_RDONLY)) {
+ unless ($file eq '-' && open(FH, '<&STDIN')) {
+ _bail("Open failed");
+ }
+ }
binmode(FH) if $binary || $portable;
unless ($portable && $text) {
@@ -639,6 +643,7 @@
The author is particularly grateful to
Gisle Aas
+ Sean Burke
Chris Carey
Alexandr Ciornii
Jim Doble
Modified: branches/upstream/libdigest-sha-perl/current/shasum
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/shasum?rev=65804&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/shasum (original)
+++ branches/upstream/libdigest-sha-perl/current/shasum Mon Dec 13 11:20:42 2010
@@ -1,11 +1,11 @@
#!perl -w
- # shasum: filter for computing SHA digests (analogous to sha1sum)
- #
- # Copyright (C) 2003-2010 Mark Shelor, All Rights Reserved
- #
- # Version: 5.48
- # Mon Jan 4 16:32:52 MST 2010
+ ## shasum: filter for computing SHA digests (ref. sha1sum/md5sum)
+ ##
+ ## Copyright (C) 2003-2010 Mark Shelor, All Rights Reserved
+ ##
+ ## Version: 5.49
+ ## Sun Dec 12 07:22:04 MST 2010
=head1 NAME
@@ -74,11 +74,11 @@
use FileHandle;
use Getopt::Long;
-my $VERSION = "5.48";
-
-
- # Try to use Digest::SHA, since it's faster. If not installed,
- # use Digest::SHA::PurePerl instead.
+my $VERSION = "5.49";
+
+
+ ## Try to use Digest::SHA, since it's faster. If not installed,
+ ## use Digest::SHA::PurePerl instead.
my $MOD_PREFER = "Digest::SHA";
my $MOD_SECOND = "Digest::SHA::PurePerl";
@@ -92,9 +92,9 @@
}
- # Usage statement adapted from Ulrich Drepper's md5sum.
- # Include an "-a" option for algorithm selection,
- # and a "-p" option for portable digest computation.
+ ## Usage statement adapted from Ulrich Drepper's md5sum.
+ ## Include an "-a" option for algorithm selection,
+ ## and a "-p" option for portable digest computation.
sub usage {
my($err, $msg) = @_;
@@ -135,7 +135,13 @@
}
- # Collect options from command line
+ ## Sync stdout and stderr by forcing a flush after every write
+
+autoflush STDOUT 1;
+autoflush STDERR 1;
+
+
+ ## Collect options from command line
my ($alg, $binary, $check, $text, $status, $warn, $help, $version);
my ($portable);
@@ -150,7 +156,7 @@
) or usage(1, "");
- # Deal with help requests and incorrect uses
+ ## Deal with help requests and incorrect uses
usage(0)
if $help;
@@ -162,14 +168,14 @@
if $status && !$check;
- # Default to SHA-1 unless overriden by command line option
+ ## Default to SHA-1 unless overriden by command line option
$alg = 1 unless defined $alg;
grep { $_ == $alg } (1, 224, 256, 384, 512)
or usage(1, "shasum: Unrecognized algorithm\n");
- # Display version information if requested
+ ## Display version information if requested
if ($version) {
print "$VERSION\n";
@@ -177,10 +183,10 @@
}
- # Try to figure out if the OS is DOS-like. If it is,
- # default to binary mode when reading files, unless
- # explicitly overriden by command line "--text" or
- # "--portable" options.
+ ## Try to figure out if the OS is DOS-like. If it is,
+ ## default to binary mode when reading files, unless
+ ## explicitly overriden by command line "--text" or
+ ## "--portable" options.
my $isDOSish = ($^O =~ /^(MSWin\d\d|os2|dos|mint|cygwin)$/);
if ($isDOSish) { $binary = 1 unless $text || $portable }
@@ -188,53 +194,73 @@
my $modesym = $binary ? '*' : ($portable ? '?' : ' ');
- # Read from STDIN (-) if no files listed on command line
+ ## Read from STDIN (-) if no files listed on command line
@ARGV = ("-") unless @ARGV;
- # sumfile($file): computes SHA digest of $file
+ ## sumfile($file): computes SHA digest of $file
sub sumfile {
my $file = shift;
my $mode = $portable ? 'p' : ($binary ? 'b' : '');
my $digest = eval { $module->new($alg)->addfile($file, $mode) };
- if ($@) {
- warn "shasum: $file: $!\n";
- return;
- }
-
+ if ($@) { warn "shasum: $file: $!\n"; return }
$digest->hexdigest;
}
- # %len2alg: maps hex digest length to SHA algorithm
+ ## %len2alg: maps hex digest length to SHA algorithm
my %len2alg = (40 => 1, 56 => 224, 64 => 256, 96 => 384, 128 => 512);
- # Verify checksums if requested
-
-if ($check) {
- my $checkfile = shift(@ARGV);
- my ($err, $read_errs, $match_errs) = (0, 0, 0);
- my ($num_files, $num_checksums) = (0, 0);
- my ($fh, $sum, $fname, $rsp, $digest);
-
- die "shasum: $checkfile: $!\n"
- unless $fh = FileHandle->new($checkfile, "r");
- while (<$fh>) {
- s/\s+$//;
- ($sum, $modesym, $fname) = /^(\S+) (.)(.*)$/;
+ ## unescape: convert backslashed filename to plain filename
+
+sub unescape {
+ $_ = shift;
+ s/\\\\/\0/g;
+ s/\\n/\n/g;
+ return if /\\/;
+ s/\0/\\/g;
+ return $_;
+}
+
+
+ ## verify: confirm the digest values in a checksum file
+
+sub verify {
+ my $checkfile = shift;
+ my ($err, $fmt_errs, $read_errs, $match_errs) = (0, 0, 0, 0);
+ my ($num_lines, $num_files, $num_checksums) = (0, 0, 0);
+ my ($bslash, $sum, $fname, $rsp, $digest);
+
+ local *FH;
+ unless (sysopen(FH, $checkfile, O_RDONLY)) {
+ unless ($checkfile eq '-' && open(FH, '<&STDIN')) {
+ _bail("Open failed");
+ }
+ $checkfile = 'standard input';
+ }
+ while (<FH>) {
+ next if /^#/; s/\n$//; s/^[ \t]+//; $num_lines++;
+ $bslash = s/^\\//;
+ ($sum, $modesym, $fname) =
+ /^([\da-fA-F]+)[ \t]([ *?])([^\0]*)/;
+ $alg = defined $sum ? $len2alg{length($sum)} : undef;
+ $fname = unescape($fname) if defined $fname && $bslash;
+ if (grep { ! defined $_ } ($alg, $sum, $modesym, $fname)) {
+ $alg = 1 unless defined $alg;
+ warn("shasum: $checkfile: $.: improperly " .
+ "formatted SHA$alg checksum line\n") if $warn;
+ $fmt_errs++;
+ next;
+ }
+ $fname =~ s/\r$// unless -e $fname;
+ $rsp = "$fname: "; $num_files++;
($binary, $portable, $text) =
map { $_ eq $modesym } ('*', '?', ' ');
- unless ($alg = $len2alg{length($sum)}) {
- warn("shasum: $checkfile: $.: improperly " .
- "formatted SHA checksum line\n") if $warn;
- next;
- }
- $rsp = "$fname: "; $num_files++;
unless ($digest = sumfile($fname)) {
$rsp .= "FAILED open or read\n";
$err = 1; $read_errs++;
@@ -246,23 +272,39 @@
}
print $rsp unless $status;
}
- $fh->close;
- unless ($status) {
- warn("shasum: WARNING: $read_errs of $num_files listed " .
- "files could not be read\n") if $read_errs;
- warn("shasum: WARNING: $match_errs of $num_checksums " .
- "computed checksums did NOT match\n") if $match_errs;
- }
- exit($err);
-}
-
-
- # Compute and display SHA checksums of requested files
+ close(FH);
+ unless ($num_files) {
+ $alg = 1 unless defined $alg;
+ warn("shasum: $checkfile: no properly formatted " .
+ "SHA$alg checksum lines found\n");
+ $err = 1;
+ }
+ elsif (! $status) {
+ warn("shasum: WARNING: $fmt_errs line" . ($fmt_errs>1?
+ 's are':' is') . " improperly formatted\n") if $fmt_errs;
+ warn("shasum: WARNING: $read_errs listed file" .
+ ($read_errs>1?'s':'') . " could not be read\n") if $read_errs;
+ warn("shasum: WARNING: $match_errs computed checksum" .
+ ($match_errs>1?'s':'') . " did NOT match\n") if $match_errs;
+ }
+ return($err == 0);
+}
+
+
+ ## Verify or compute SHA checksums of requested files
my($file, $digest);
+my $STATUS = 0;
for $file (@ARGV) {
- if ($digest = sumfile($file)) {
+ if ($check) { $STATUS = 1 unless verify($file) }
+ elsif ($digest = sumfile($file)) {
+ if ($file =~ /[\n\\]/) {
+ $file =~ s/\\/\\\\/g; $file =~ s/\n/\\n/g;
+ $digest = "\\$digest";
+ }
print "$digest $modesym", "$file\n";
}
-}
+ else { $STATUS = 1 }
+}
+exit($STATUS)
Modified: branches/upstream/libdigest-sha-perl/current/src/hmac.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/src/hmac.c?rev=65804&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/src/hmac.c (original)
+++ branches/upstream/libdigest-sha-perl/current/src/hmac.c Mon Dec 13 11:20:42 2010
@@ -5,8 +5,8 @@
*
* Copyright (C) 2003-2010 Mark Shelor, All Rights Reserved
*
- * Version: 5.48
- * Mon Jan 4 16:32:52 MST 2010
+ * Version: 5.49
+ * Sun Dec 12 07:22:04 MST 2010
*
*/
Modified: branches/upstream/libdigest-sha-perl/current/src/hmac.h
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/src/hmac.h?rev=65804&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/src/hmac.h (original)
+++ branches/upstream/libdigest-sha-perl/current/src/hmac.h Mon Dec 13 11:20:42 2010
@@ -5,8 +5,8 @@
*
* Copyright (C) 2003-2010 Mark Shelor, All Rights Reserved
*
- * Version: 5.48
- * Mon Jan 4 16:32:52 MST 2010
+ * Version: 5.49
+ * Sun Dec 12 07:22:04 MST 2010
*
*/
Modified: branches/upstream/libdigest-sha-perl/current/src/sha.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/src/sha.c?rev=65804&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/src/sha.c (original)
+++ branches/upstream/libdigest-sha-perl/current/src/sha.c Mon Dec 13 11:20:42 2010
@@ -5,8 +5,8 @@
*
* Copyright (C) 2003-2010 Mark Shelor, All Rights Reserved
*
- * Version: 5.48
- * Mon Jan 4 16:32:52 MST 2010
+ * Version: 5.49
+ * Sun Dec 12 07:22:04 MST 2010
*
*/
Modified: branches/upstream/libdigest-sha-perl/current/src/sha.h
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdigest-sha-perl/current/src/sha.h?rev=65804&op=diff
==============================================================================
--- branches/upstream/libdigest-sha-perl/current/src/sha.h (original)
+++ branches/upstream/libdigest-sha-perl/current/src/sha.h Mon Dec 13 11:20:42 2010
@@ -5,8 +5,8 @@
*
* Copyright (C) 2003-2010 Mark Shelor, All Rights Reserved
*
- * Version: 5.48
- * Mon Jan 4 16:32:52 MST 2010
+ * Version: 5.49
+ * Sun Dec 12 07:22:04 MST 2010
*
*/
More information about the Pkg-perl-cvs-commits
mailing list