From: Steve Peters Date: Mon, 15 May 2006 14:13:46 +0000 (+0000) Subject: Upgrade to Digest-SHA-5.37 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dcbcf62d607409d46996d4329bf404ad7568adcb;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Digest-SHA-5.37 p4raw-id: //depot/perl@28197 --- diff --git a/ext/Digest/SHA/Changes b/ext/Digest/SHA/Changes index aed90cb..18d1213 100644 --- a/ext/Digest/SHA/Changes +++ b/ext/Digest/SHA/Changes @@ -1,5 +1,15 @@ Revision history for Perl extension Digest::SHA. +5.37 Mon May 8 04:30:09 MST 2006 + - modified shasum to avoid file slurping (ref. sub sumfile) + - improved error handling of checksum files in shasum + -- to better mimic the behavior of md5sum + - refined line-break regex in shasum (ref. sub sumfile) + -- catches multiple CR's preceding LF + thanks to Gisle Aas for suggested patch + - changed loop vars to signed int's in shadump (ref. src/sha.c) + -- to prevent type mismatch warnings + 5.36 Mon May 8 01:38:36 MST 2006 - fixed the "portable" option in shasum -- normalize line-breaks in text files only diff --git a/ext/Digest/SHA/README b/ext/Digest/SHA/README index 2342d3a..fcdea0f 100644 --- a/ext/Digest/SHA/README +++ b/ext/Digest/SHA/README @@ -1,4 +1,4 @@ -Digest::SHA version 5.36 +Digest::SHA version 5.37 ======================== Digest::SHA is a complete implementation of the NIST Secure Hash diff --git a/ext/Digest/SHA/bin/shasum b/ext/Digest/SHA/bin/shasum index 474a45f..0c28719 100755 --- a/ext/Digest/SHA/bin/shasum +++ b/ext/Digest/SHA/bin/shasum @@ -4,8 +4,8 @@ # # Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved # - # Version: 5.36 - # Mon May 8 01:38:36 MST 2006 + # Version: 5.37 + # Mon May 8 04:30:09 MST 2006 =head1 NAME @@ -52,7 +52,7 @@ L. use strict; use Getopt::Long; -my $VERSION = "5.36"; +my $VERSION = "5.37"; # Try to use Digest::SHA, since it's faster. If not installed, @@ -174,25 +174,29 @@ my $mode = $binary ? '*' : ($portable ? '?' : ' '); # sumfile($file): computes SHA digest of $file sub sumfile { - my($file) = @_; - my($fh, $digest); + my $file = shift; - unless (open($fh, "<$file")) { - print STDERR "shasum: $file: No such file or directory\n"; - return; - } - binmode($fh) if $binary || $portable; - - local $/; - my $buf = <$fh>; - close($fh); + local *F; + return unless open(F, "<$file"); + binmode(F) if $binary || $portable; + my $digest = $module->new($alg); if ($portable && -T $file) { - $buf =~ s/\015\012/\012/g; - $buf =~ s/\015/\012/g; + local $/ = \4096; + while (defined (my $rec = )) { + while (substr($rec, -1) eq "\015") { + defined (my $extra = ) or last; + $rec .= $extra; + } + $rec =~ s/\015+\012/\012/g; + $rec =~ s/\015/\012/g; + $digest->add($rec); + } } + else { $digest->addfile(*F) } + close(F); - $digest = $module->new($alg)->add($buf)->hexdigest; + $digest->hexdigest; } @@ -213,16 +217,26 @@ if ($check) { while (<$fh>) { s/\s+$//; ($sum, $mode, $fname) = /^(\S+) (.)(.*)$/; + unless (-e $fname) { + warn "shasum: $fname: No such file or directory\n"; + next; + } ($binary, $portable, $text) = map { $_ eq $mode } ('*', '?', ' '); unless ($alg = $len2alg{length($sum)}) { - print STDERR "shasum: $checkfile: $.: improperly ", - "formatted SHA checksum line\n" if $warn; + warn("shasum: $checkfile: $.: improperly " . + "formatted SHA checksum line\n") if $warn; next; } $rsp = "$fname: "; - if (lc($sum) eq sumfile($fname)) { $rsp .= "OK\n" } - else { $rsp .= "FAILED\n"; $err = 1 } + unless (my $digest = sumfile($fname)) { + $rsp .= "FAILED open or read\n"; + $err = 1; + } + else { + if (lc($sum) eq $digest) { $rsp .= "OK\n" } + else { $rsp .= "FAILED\n"; $err = 1 } + } print $rsp unless $status; } close($fh); @@ -232,11 +246,11 @@ if ($check) { # Compute and display SHA checksums of requested files -for (@ARGV) { - if (-d $_) { - print STDERR "shasum: $_: Is a directory\n"; +for my $arg (@ARGV) { + if (-d $arg) { + print STDERR "shasum: $arg: Is a directory\n"; next; } - next unless my $digest = sumfile($_); - print "$digest $mode", "$_\n"; + next unless my $digest = sumfile($arg); + print "$digest $mode", "$arg\n"; } diff --git a/ext/Digest/SHA/src/hmac.c b/ext/Digest/SHA/src/hmac.c index 6c81452..e423bd5 100644 --- a/ext/Digest/SHA/src/hmac.c +++ b/ext/Digest/SHA/src/hmac.c @@ -5,8 +5,8 @@ * * Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved * - * Version: 5.36 - * Mon May 8 01:38:36 MST 2006 + * Version: 5.37 + * Mon May 8 04:30:09 MST 2006 * */ diff --git a/ext/Digest/SHA/src/hmac.h b/ext/Digest/SHA/src/hmac.h index cf4255e..43a7afa 100644 --- a/ext/Digest/SHA/src/hmac.h +++ b/ext/Digest/SHA/src/hmac.h @@ -5,8 +5,8 @@ * * Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved * - * Version: 5.36 - * Mon May 8 01:38:36 MST 2006 + * Version: 5.37 + * Mon May 8 04:30:09 MST 2006 * */ diff --git a/ext/Digest/SHA/src/sha.c b/ext/Digest/SHA/src/sha.c index 2b2db5a..47a18fe 100644 --- a/ext/Digest/SHA/src/sha.c +++ b/ext/Digest/SHA/src/sha.c @@ -5,8 +5,8 @@ * * Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved * - * Version: 5.36 - * Mon May 8 01:38:36 MST 2006 + * Version: 5.37 + * Mon May 8 04:30:09 MST 2006 * */ @@ -517,7 +517,7 @@ int shadump(file, s) char *file; SHA *s; { - unsigned int i, j; + int i, j; SHA_FILE *f; UCHR *p = shadigest(s); @@ -530,7 +530,7 @@ SHA *s; for (j = 0; j < (UINT) (s->alg <= 256 ? 4 : 8); j++) SHA_fprintf(f, "%s%02x", j==0 ? ":" : "", *p++); SHA_fprintf(f, "\nblock"); - for (i = 0; i < s->blocksize>>3; i++) + for (i = 0; i < (int) (s->blocksize >> 3); i++) SHA_fprintf(f, ":%02x", s->block[i]); SHA_fprintf(f, "\nblockcnt:%u\n", s->blockcnt); SHA_fprintf(f, "lenhh:%lu\nlenhl:%lu\nlenlh:%lu\nlenll:%lu\n", diff --git a/ext/Digest/SHA/src/sha.h b/ext/Digest/SHA/src/sha.h index b929543..95597d3 100644 --- a/ext/Digest/SHA/src/sha.h +++ b/ext/Digest/SHA/src/sha.h @@ -5,8 +5,8 @@ * * Copyright (C) 2003-2006 Mark Shelor, All Rights Reserved * - * Version: 5.36 - * Mon May 8 01:38:36 MST 2006 + * Version: 5.37 + * Mon May 8 04:30:09 MST 2006 * */