When ddrescue starts writing files and log file and output file are the same file, it opens output file first and log file after that and as a result, if you give those both files the same name, you will have only the log file as a result. This patch makes it harder to do mistakes like that by aborting if output file name and log file name are the same.

This does not protect against cases where you use full path for one file and relative for another or symbolic links but those kind of file name screw-ups are probably harder to do by accident.

--
Jussi Judin
https://jjudin.iki.fi/
--- ddrescue-1.14/main.cc	2011-01-10 20:54:14.000000000 +0200
+++ ddrescue-1.14-checksamefile/main.cc	2011-05-20 13:24:38.875108290 +0300
@@ -573,6 +573,8 @@
   if( argind < parser.arguments() ) iname = parser.argument( argind++ ).c_str();
   if( argind < parser.arguments() ) oname = parser.argument( argind++ ).c_str();
   if( argind < parser.arguments() ) logname = parser.argument( argind++ ).c_str();
+  if( strcmp(oname, logname) == 0)
+    { show_error( "Output file and log file are the same file." ); return 1; }
   if( argind < parser.arguments() )
     { show_error( "Too many files.", 0, true ); return 1; }
 
_______________________________________________
Bug-ddrescue mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-ddrescue

Reply via email to