classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] Re: Security manager problem


From: Mark Wielaard
Subject: [cp-patches] Re: Security manager problem
Date: Thu, 22 Dec 2005 17:53:43 +0100

Hi Gary (and moved to classpath-patches),

On Thu, 2005-12-22 at 15:15 +0000, Gary Benson wrote:
> > Aha! There is your clue. libgcj hasn't merged in the new nio charset
> > provider setup. And indeed creating a new CharsetProvider requires a
> > RuntimePermission("charsetProvider"). Even for creating the default
> > provider. Which obviously should always be created, otherwise
> > nothing works. It is safe in this case since we know the default
> > provider doesn't do nasty things (or at least we hope so). So you
> > need the attached patch to gnu/java/nio/charset/Provider.java.
> 
> Works perfectly, thanks.

And so this will be checked in:

2005-12-22  Mark Wielaard  <address@hidden>

    * gnu/java/nio/charset/Provider.java (provider): Wrap initialization
    of standard provider in a PrivilegedAction.

Cheers,

Mark
Index: gnu/java/nio/charset/Provider.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/nio/charset/Provider.java,v
retrieving revision 1.6
diff -u -r1.6 Provider.java
--- gnu/java/nio/charset/Provider.java  2 Jul 2005 20:32:13 -0000       1.6
+++ gnu/java/nio/charset/Provider.java  13 Dec 2005 18:38:18 -0000
@@ -39,6 +39,8 @@
 
 import java.nio.charset.Charset;
 import java.nio.charset.spi.CharsetProvider;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -232,8 +234,16 @@
 
   public static synchronized Provider provider ()
   {
+    // The default provider is safe to instantiate.
     if (singleton == null)
-      singleton = new Provider ();
+      singleton = (Provider) AccessController.doPrivileged
+       (new PrivilegedAction()
+         {
+           public Object run()
+           {
+             return new Provider();
+           }
+         });
     return singleton;
   }
 }

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]