#
- # If recovery file is zero length, remove it.
- # Else send mail to the user.
+ # Make a copy of the backup file path.
+ # We must not modify @backups directly since it contains
+ # references to data in @recfile which we pipe to sendmail.
#
- $backups[0] =~ /^X-vi-recover-path:\s*(.*)[\r\n]*$/;
+ $backups[0] =~ m#^X-vi-recover-path:\s*\Q$recoverdir\E/+(.*)[\r\n]*$#;
$backup = $1;
- if (! -s $backup) {
+
+ #
+ # If backup file is not rooted in the recover dir, ignore it.
+ # If backup file owner doesn't match recovery file owner, ignore it.
+ # If backup file is zero length or not a regular file, remove it.
+ # Else send mail to the user.
+ #
+ if ($backup =~ m#/# || !lstat($backup)) {
+ unlink($file);
+ } elsif ($owner != 0 && (stat(_))[4] != $owner) {
+ unlink($file);
+ } elsif (! -f _ || ! -s _) {
unlink($file, $backup);
} else {
open(SENDMAIL, "|$sendmail -t") ||