--- a/restore/tape.c
+++ b/restore/tape.c
@@ -1421,8 +1421,10 @@ loop:
 		last_write_was_hole = 1;
 	}
 	if (last_write_was_hole) {
-		if (ftruncate(ofile, origsize) < 0)
-			warn("%s: ftruncate", curfile.name);
+		 /* do not attempt a truncate if running an on-the-fly compare, as there
+				IS no file to truncate in that case! */
+		 if (ofile >= 0 && ftruncate(ofile, origsize) < 0)
+				warn("%s: ftruncate", curfile.name);
 	}
 	if (!readingmaps)
 		findinode(&spcl);
@@ -1901,6 +1903,7 @@ comparefile(char *name)
 		}
 		else {
 			cmperror = 0;
+			ofile = -1;	/* instruct getfile to not truncate as there is no open file: xtrcmpfile works off mem buffer */
 			getfile(xtrcmpfile, xtrcmpskip);
 			if (!cmperror) {
 				char c;
