[Mono-bugs] [Bug 79118][Min] New - FileIOPermission.UnionKeys only considers first entry of list

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Aug 20 06:12:36 EDT 2006


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 peter.dettman at iinet.net.au.

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

--- shadow/79118	2006-08-20 06:12:36.000000000 -0400
+++ shadow/79118.tmp.1168	2006-08-20 06:12:36.000000000 -0400
@@ -0,0 +1,65 @@
+Bug#: 79118
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: System.Security
+AssignedTo: sebastien at ximian.com                            
+ReportedBy: peter.dettman at iinet.net.au               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: FileIOPermission.UnionKeys only considers first entry of list
+
+Description of Problem:
+
+I noticed a compiler warning whilst building mcs:
+
+System.Security.Permissions/FileIOPermission.cs(531,30): warning CS0162:
+Unreachable code detected
+
+This is an issue in the FileIOPermission.UnionKeys method.
+
+Looking at the code, I noticed that the logic was a bit buggy, the inner
+loop will never look at more than one of the list entries.
+
+Here is a short test program that reveals the issue:
+
+--------------------
+using System;
+using System.Security.Permissions;
+
+public class Program {
+    static public int Main (string[] args)
+    {
+        FileIOPermission fiopA = new FileIOPermission(
+            FileIOPermissionAccess.Read,
+            new string[] { "/tmp/one", "/tmp/two" });
+
+        FileIOPermission fiopB = new FileIOPermission(
+            FileIOPermissionAccess.Read,
+            new string[] { "/tmp/two" });
+
+        FileIOPermission fiopC = (FileIOPermission) fiopA.Union(fiopB);
+        string[] paths = fiopC.GetPathList(FileIOPermissionAccess.Read);
+
+        if (paths.Length > 2) {
+            Console.WriteLine("Union didn't remove duplicate");
+            foreach (string path in paths) {
+                Console.WriteLine(path);
+            }
+            return 1;
+        }
+
+        Console.WriteLine ("OK");
+        return 0;
+    }
+}
+--------------------
+
+A patch to fix follows.


More information about the mono-bugs mailing list