public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* FYI: Catch unexpected permission check exceptions
@ 2005-12-05 15:59 Gary Benson
  0 siblings, 0 replies; only message in thread
From: Gary Benson @ 2005-12-05 15:59 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 170 bytes --]

Hi,

This patch wraps the tests in java/io/File*Stream/security.java 
with try-catch blocks to catch SecurityExceptions thrown by extra
permissions checks.

Cheers,
Gary

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 5839 bytes --]

Index: ChangeLog
===================================================================
RCS file: /cvs/mauve/mauve/ChangeLog,v
retrieving revision 1.1275
diff -u -r1.1275 ChangeLog
--- ChangeLog	5 Dec 2005 15:28:11 -0000	1.1275
+++ ChangeLog	5 Dec 2005 15:53:57 -0000
@@ -1,5 +1,11 @@
 2005-12-02  Gary Benson <gbenson@redhat.com>
 
+	* gnu/testlet/java/io/FileInputStream/security.java: Catch
+	exceptions generated by unexpected permission checks..
+	* gnu/testlet/java/io/FileOutputStream/security.java: Likewise.
+
+2005-12-02  Gary Benson <gbenson@redhat.com>
+
 	* gnu/testlet/java/io/RandomAccessFile/security.java: New tests.
 
 2005-12-02  Gary Benson <gbenson@redhat.com>
Index: gnu/testlet/java/io/FileInputStream/security.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/io/FileInputStream/security.java,v
retrieving revision 1.2
diff -u -r1.2 security.java
--- gnu/testlet/java/io/FileInputStream/security.java	5 Dec 2005 10:49:00 -0000	1.2
+++ gnu/testlet/java/io/FileInputStream/security.java	5 Dec 2005 15:53:57 -0000
@@ -47,21 +47,39 @@
 	
       // security: java.io.FileInputStream-FileInputStream(File)
       harness.checkPoint("File constructor");
-      sm.prepareChecks(new Permission[] {perm}, new Permission[] {});
-      new FileInputStream(file);
-      sm.checkAllChecked(harness);
+      try {
+	sm.prepareChecks(new Permission[] {perm}, new Permission[] {});
+	new FileInputStream(file);
+	sm.checkAllChecked(harness);
+      }
+      catch (SecurityException ex) {
+	harness.debug(ex);
+	harness.check(false, "Unexpected check");
+      }
       
       // security: java.io.FileInputStream-FileInputStream(String)
       harness.checkPoint("String constructor");
-      sm.prepareChecks(new Permission[] {perm}, new Permission[] {});
-      new FileInputStream(path);
-      sm.checkAllChecked(harness);
+      try {
+	sm.prepareChecks(new Permission[] {perm}, new Permission[] {});
+	new FileInputStream(path);
+	sm.checkAllChecked(harness);
+      }
+      catch (SecurityException ex) {
+	harness.debug(ex);
+	harness.check(false, "Unexpected check");
+      }
       
       // security: java.io.FileInputStream-FileInputStream(FileDescriptor)
       harness.checkPoint("FileDescriptor constructor");
-      sm.prepareChecks(new Permission[] {fdPerm}, new Permission[] {});
-      new FileInputStream(FileDescriptor.in);
-      sm.checkAllChecked(harness);
+      try {
+	sm.prepareChecks(new Permission[] {fdPerm}, new Permission[] {});
+	new FileInputStream(FileDescriptor.in);
+	sm.checkAllChecked(harness);
+      }
+      catch (SecurityException ex) {
+	harness.debug(ex);
+	harness.check(false, "Unexpected check");
+      }
     }
     catch (Throwable ex) {
       harness.debug(ex);
Index: gnu/testlet/java/io/FileOutputStream/security.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/io/FileOutputStream/security.java,v
retrieving revision 1.3
diff -u -r1.3 security.java
--- gnu/testlet/java/io/FileOutputStream/security.java	5 Dec 2005 11:05:34 -0000	1.3
+++ gnu/testlet/java/io/FileOutputStream/security.java	5 Dec 2005 15:53:57 -0000
@@ -51,37 +51,67 @@
 	
       // security: java.io.FileOutputStream-FileOutputStream(File)
       harness.checkPoint("File constructor");
-      sm.prepareChecks(new Permission[] {wperm}, new Permission[] {rperm});
-      new FileOutputStream(file);
-      sm.checkAllChecked(harness);
+      try {
+	sm.prepareChecks(new Permission[] {wperm}, new Permission[] {rperm});
+	new FileOutputStream(file);
+	sm.checkAllChecked(harness);
+      }
+      catch (SecurityException ex) {
+	harness.debug(ex);
+	harness.check(false, "Unexpected check");
+      }
 
       // security: java.io.FileOutputStream-FileOutputStream(File, boolean)
       harness.checkPoint("File, boolean constructor");
       for (int i = 0; i <= 1; i++) {
+	try {
 	  sm.prepareChecks(new Permission[] {wperm}, new Permission[] {rperm});
 	  new FileOutputStream(file, i == 1);
 	  sm.checkAllChecked(harness);
+	}
+	catch (SecurityException ex) {
+	  harness.debug(ex);
+	  harness.check(false, "Unexpected check");
+	}
       }
 
       // security: java.io.FileOutputStream-FileOutputStream(String)
       harness.checkPoint("String constructor");
-      sm.prepareChecks(new Permission[] {wperm}, new Permission[] {rperm});
-      new FileOutputStream(path);
-      sm.checkAllChecked(harness);
+      try {
+	sm.prepareChecks(new Permission[] {wperm}, new Permission[] {rperm});
+	new FileOutputStream(path);
+	sm.checkAllChecked(harness);
+      }
+      catch (SecurityException ex) {
+	harness.debug(ex);
+	harness.check(false, "Unexpected check");
+      }
 
       // security: java.io.FileOutputStream-FileOutputStream(String, boolean)
       harness.checkPoint("String, boolean constructor");
       for (int i = 0; i <= 1; i++) {
+	try {
 	  sm.prepareChecks(new Permission[] {wperm}, new Permission[] {rperm});
 	  new FileOutputStream(path, i == 1);
 	  sm.checkAllChecked(harness);
+	}
+	catch (SecurityException ex) {
+	  harness.debug(ex);
+	  harness.check(false, "Unexpected check");
+	}
       }
 
       // security: java.io.FileOutputStream-FileOutputStream(FileDescriptor)
       harness.checkPoint("FileDescriptor constructor");
-      sm.prepareChecks(new Permission[] {fdPerm}, new Permission[] {});
-      new FileOutputStream(FileDescriptor.out);
-      sm.checkAllChecked(harness);
+      try {
+	sm.prepareChecks(new Permission[] {fdPerm}, new Permission[] {});
+	new FileOutputStream(FileDescriptor.out);
+	sm.checkAllChecked(harness);
+      }
+      catch (SecurityException ex) {
+	harness.debug(ex);
+	harness.check(false, "Unexpected check");
+      }
     }
     catch (Throwable ex) {
       harness.debug(ex);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-12-05 15:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-05 15:59 FYI: Catch unexpected permission check exceptions Gary Benson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).