[Mono-bugs] [Bug 24199] New - System.IO.File.Copy error checking bug

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
3 May 2002 20:04:03 -0000


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by mike@mikegray.org.

http://bugzilla.ximian.com/show_bug.cgi?id=24199

--- shadow/24199	Fri May  3 16:04:03 2002
+++ shadow/24199.tmp.17577	Fri May  3 16:04:03 2002
@@ -0,0 +1,68 @@
+Bug#: 24199
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: mike@mikegray.org               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: System.IO.File.Copy error checking bug
+
+I was just starting to review some code and believe I found a problem in
+the error checking in System.IO.File.Copy().  In CVS, revision 1.9, look at
+ the implementation of function with signature of "Copy (string src, string
+dest, bool overwrite)".  
+http://cvs.hispalinux.es/cgi-bin/cvsweb/mcs/class/corlib/System.IO/File.cs?rev=1.9&content-type=text/x-cvsweb-markup&cvsroot=Mono
+
+First condition checks for either parameter being null.  Second if
+conditional checks for empty string of src, but then checks for dest being
+null again.  This should actually check for dest being empty string.
+
+Here is the patch:
+cvs server: Diffing .
+Index: File.cs
+===================================================================
+RCS file: /mono/mcs/class/corlib/System.IO/File.cs,v
+retrieving revision 1.9
+diff -c -r1.9 File.cs
+*** File.cs	3 Apr 2002 06:28:50 -0000	1.9
+--- File.cs	3 May 2002 20:02:51 -0000
+***************
+*** 36,42 ****
+  		{
+
+  	
+	if (src == null || dest == null)
+  	
+		throw new ArgumentNullException ();
+! 	
+	if (src == "" || dest == null ||
+  	
+	    src.IndexOfAny (Path.InvalidPathChars) != -1 ||
+  	
+	    dest.IndexOfAny (Path.InvalidPathChars) != -1)
+  	
+		throw new ArgumentException ();
+--- 36,42 ----
+  		{
+
+  	
+	if (src == null || dest == null)
+  	
+		throw new ArgumentNullException ();
+! 	
+	if (src == "" || dest == "" ||
+  	
+	    src.IndexOfAny (Path.InvalidPathChars) != -1 ||
+  	
+	    dest.IndexOfAny (Path.InvalidPathChars) != -1)
+  	
+		throw new ArgumentException ();