[Mono-bugs] [Bug 55362][Maj] New - File.SetAttributes(path,FileAttributes) does not throw PathTooLongException

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 9 Mar 2004 08:44:55 -0500 (EST)


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 nrathna@novell.com.

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

--- shadow/55362	2004-03-09 08:44:55.000000000 -0500
+++ shadow/55362.tmp.32040	2004-03-09 08:44:55.000000000 -0500
@@ -0,0 +1,226 @@
+Bug#: 55362
+Product: Mono: Class Libraries
+Version: unspecified
+OS: Red Hat 8.0
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: nrathna@novell.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: File.SetAttributes(path,FileAttributes) does not throw PathTooLongException
+
+Description of Problem:
+File.SetAttributes(path,FileAttributes) does not throw PathTooLongException
+
+Steps to reproduce the problem:
+1. File.SetAttributes(path,FileAttributes)  with path having more than 286 
+chars
+
+string path ="abcdefghijklmnopqrstuvwxyz"    
+path=path+path+path+path+path+path+path+path+path+path+path;
+		
+		[Test]
+		[ExpectedException (typeof (PathTooLongException))]
+		public void FileSetAttributesArchive()
+		{
+			try
+			{
+				File.SetAttributes
+(path,FileAttributes.Archive);
+			}
+			finally {}
+		}
+		
+		[Test]
+		[ExpectedException (typeof (PathTooLongException))]
+		public void FileSetAttributesCompressed()
+		{
+			try
+			{
+				File.SetAttributes
+(path,FileAttributes.Compressed);
+			}
+			finally {}
+		}
+		
+		[Test]
+		[ExpectedException (typeof (PathTooLongException))]
+		public void FileSetAttributesDevice()
+		{
+			try
+			{
+				File.SetAttributes
+(path,FileAttributes.Device);
+			}
+			finally {}
+		}
+		
+		[Test]
+		[ExpectedException (typeof (PathTooLongException))]
+		public void FileSetAttributesDirectory()
+		{
+			try
+			{
+				File.SetAttributes
+(path,FileAttributes.Directory);
+			}
+			finally {}
+		}
+		
+		[Test]
+		[ExpectedException (typeof (PathTooLongException))]
+		public void FileSetAttributesEncrypted()
+		{
+			try
+			{
+				File.SetAttributes
+(path,FileAttributes.Encrypted);
+			}
+			finally {}
+		}
+		
+		[Test]
+		[ExpectedException (typeof (PathTooLongException))]
+		public void FileSetAttributesHidden()
+		{
+			try
+			{
+				File.SetAttributes
+(path,FileAttributes.Hidden);
+			}
+			finally {}
+		}
+		
+		[Test]
+		[ExpectedException (typeof (PathTooLongException))]
+		public void FileSetAttributesNormal()
+		{
+			try
+			{
+				File.SetAttributes
+(path,FileAttributes.Normal);
+			}
+			finally {}
+		}
+		
+		[Test]
+		[ExpectedException (typeof (PathTooLongException))]
+		public void FileSetAttributesNotContentIndexed()
+		{
+			try
+			{
+				File.SetAttributes
+(path,FileAttributes.NotContentIndexed);
+			}
+			finally {}
+		}
+		
+		[Test]
+		[ExpectedException (typeof (PathTooLongException))]
+		public void FileSetAttributesOffline()
+		{
+			try
+			{
+				File.SetAttributes
+(path,FileAttributes.Offline);
+			}
+			finally {}
+		}
+		
+		[Test]
+		[ExpectedException (typeof (PathTooLongException))]
+		public void FileSetAttributesReadOnly()
+		{
+			try
+			{
+				File.SetAttributes
+(path,FileAttributes.ReadOnly);
+			}
+			finally {}
+		}
+		
+		[Test]
+		[ExpectedException (typeof (PathTooLongException))]
+		public void FileSetAttributesReparsePoint()
+		{
+			try
+			{
+				File.SetAttributes
+(path,FileAttributes.ReparsePoint);
+			}
+			finally {}
+		}
+		
+		[Test]
+		[ExpectedException (typeof (PathTooLongException))]
+		public void FileSetAttributesParseFile()
+		{
+			try
+			{
+				File.SetAttributes
+(path,FileAttributes.SparseFile);
+			}
+			finally {}
+		}
+		
+		[Test]
+		[ExpectedException (typeof (PathTooLongException))]
+		public void FileSetAttributesSystem()
+		{
+			try
+			{
+				File.SetAttributes
+(path,FileAttributes.System);
+			}
+			finally {}
+		}
+		
+		[Test]
+		[ExpectedException (typeof (PathTooLongException))]
+		public void FileSetAttributesTemporary()
+		{
+			try
+			{
+				File.SetAttributes
+(path,FileAttributes.Temporary);
+			}
+			finally {}
+		}
+		
+Actual Results:
+throws FileNotFoundException
+
+Expected Results:
+Should throw PathTooLongException
+
+How often does this happen? 
+Continous
+
+Additional Information:
+Should check for the path length before passing it to a method
+
+Stack Trace:
+                          
+in [0x0001b] 
+(at /home/rathna/monoCVS/mcs/class/corlib/System.IO/File.cs:284) 
+System.IO.File:SetAttributes (string,System.IO.FileAttributes)
+in <0x00015> 
+MonoTests.System.IO.PathTooLongExceptionTest:FileSetAttributesArchive ()
+in (unmanaged) /usr/local/lib/libmono.so.0 [0x4004415b]
+in (unmanaged) /usr/local/lib/libmono.so.0(mono_runtime_invoke+0x23) 
+[0x4007db9f]
+in (unmanaged) /usr/local/lib/libmono.so.0
+(mono_runtime_invoke_array+0x119) [0x4007e8f1]
+in (unmanaged) /usr/local/lib/libmono.so.0 [0x400848d4]
+in [0x00033] 
+(at /home/rathna/monoCVS/mcs/class/corlib/System.Reflection/MonoMethod.cs:9
+8) System.Reflection.MonoMethod:Invoke 
+(object,System.Reflection.BindingFlags,System.Reflection.Binder,object
+[],System.Globalization.CultureInfo)