diff options
author | John Leuner <jewel@pixie.co.za> | 2003-03-20 17:04:01 +0000 |
---|---|---|
committer | John Leuner <jewel@pixie.co.za> | 2003-03-20 17:04:01 +0000 |
commit | 59e4c763c9b7695d58048589f3b80a6510ecfbc4 (patch) | |
tree | 6a405a5cb8d8248308e0df0847c4402b7708eb02 /java | |
parent | 31f095420300c11f27be1fdbdc98e0fffe39fb81 (diff) | |
download | classpath-59e4c763c9b7695d58048589f3b80a6510ecfbc4.tar.gz |
Patches from Stephen Crawley
* java/util/PropertyPermission.java: Fix to prevent recursive
call during
initialization
* java/io/FileDescriptor.java (close) : clear nativeFD on
success
* java/net/PlainDatagramSocketImpl.java (setTTL): remap the TTL
passed
as an unsigned byte to an integer in the range 0..255
* native/jni/java-net/javanet.c (_javanet_get_option):
implement ..._get(SOCKOPT_SO_BINDADDR) -> 'getsockname'
syscall
* native/jni/java-net/javanet.c (_javanet_set_option):
implement ..._set(SOCKOPT_SO_BINDADDR) -> Exception
Diffstat (limited to 'java')
-rw-r--r-- | java/io/FileDescriptor.java | 4 | ||||
-rw-r--r-- | java/net/PlainDatagramSocketImpl.java | 5 | ||||
-rw-r--r-- | java/util/PropertyPermission.java | 29 |
3 files changed, 32 insertions, 6 deletions
diff --git a/java/io/FileDescriptor.java b/java/io/FileDescriptor.java index 84c830c6d..fc3e1fd77 100644 --- a/java/io/FileDescriptor.java +++ b/java/io/FileDescriptor.java @@ -197,12 +197,12 @@ public final class FileDescriptor { if (nativeFd == -1L) return; - try { nativeClose(nativeFd); + nativeFd = -1L; } - catch(IOException e) + catch (IOException e) { nativeFd = -1L; throw new IOException(e.getMessage()); diff --git a/java/net/PlainDatagramSocketImpl.java b/java/net/PlainDatagramSocketImpl.java index fadc77851..42868edde 100644 --- a/java/net/PlainDatagramSocketImpl.java +++ b/java/net/PlainDatagramSocketImpl.java @@ -191,7 +191,10 @@ public class PlainDatagramSocketImpl extends DatagramSocketImpl */ protected synchronized void setTTL(byte ttl) throws IOException { - setOption(IP_TTL, new Integer(ttl)); + if (ttl > 0) + setOption(IP_TTL, new Integer(ttl)); + else + setOption(IP_TTL, new Integer(ttl + 256)); } /** diff --git a/java/util/PropertyPermission.java b/java/util/PropertyPermission.java index bb03e45f3..0d439d888 100644 --- a/java/util/PropertyPermission.java +++ b/java/util/PropertyPermission.java @@ -121,7 +121,7 @@ public final class PropertyPermission extends BasicPermission super(name); if (actions == null) throw new IllegalArgumentException(); - setActions(actions.toLowerCase()); + setActions(actions); } /** @@ -134,14 +134,37 @@ public final class PropertyPermission extends BasicPermission */ private void setActions(String str) { + // Initialising the class java.util.Locale ... + // tries to initialise the Locale.defaultLocale static + // which calls System.getProperty, + // which calls SecurityManager.checkPropertiesAccess, + // which creates a PropertyPermission with action "read,write", + // which calls setActions("read,write"). + // If we now were to call toLowerCase on 'str', + // this would call Locale.getDefault() which returns null + // because Locale.defaultLocale hasn't been set yet + // then toLowerCase will fail with a null pointer exception. + // + // The solution is to take a punt on 'str' being lower case, and + // test accordingly. If that fails, we convert 'str' to lower case + // and try the tests again. if ("read".equals(str)) actions = READ; else if ("write".equals(str)) actions = WRITE; else if ("read,write".equals(str) || "write,read".equals(str)) actions = READ | WRITE; - else - throw new IllegalArgumentException("illegal action " + str); + else { + String lstr = str.toLowerCase(); + if ("read".equals(lstr)) + actions = READ; + else if ("write".equals(lstr)) + actions = WRITE; + else if ("read,write".equals(lstr) || "write,read".equals(lstr)) + actions = READ | WRITE; + else + throw new IllegalArgumentException("illegal action " + str); + } } /** |