- return -5 if ( sysseek($fh2, $eofPosn, 0) != $eofPosn );
- return -6 if ( syswrite($fh2, $data2) != length($data2) );
- return -7 if ( !defined(sysseek($fh2, 0, 0)) );
- return -8 if ( syswrite($fh2, chr(0xd6)) != 1 );
+ return -110 if ( syswrite($fh2, $data2) != length($data2) );
+ if ( $verify ) {
+ #
+ # Make sure there is no extraneous data on the end of
+ # the file. Seek to the end and truncate if it doesn't
+ # match our expected length.
+ #
+ return -111 if ( !defined(sysseek($fh2, 0, 2)) );
+ if ( tell($fh2) != $eofPosn + length($data2) ) {
+ if ( !truncate($fh2, $eofPosn + length($data2)) ) {
+ &$Log(sprintf("digestAdd: $file truncate from %d to %d failed",
+ tell($fh2), $eofPosn + length($data2)));
+ return -112;
+ } else {
+ &$Log(sprintf("digestAdd: $file truncated from %d to %d",
+ tell($fh2), $eofPosn + length($data2)));
+ }
+ }
+ }
+ return -113 if ( !defined(sysseek($fh2, 0, 0)) );
+ return -114 if ( syswrite($fh2, chr(0xd6)) != 1 );