mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 17:39:40 +01:00
Compare commits
117 Commits
jdk-19+34
...
jdk-11.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fefb969cdd | ||
|
|
0ec4029c81 | ||
|
|
7d10c5bc0a | ||
|
|
bbc1638ce1 | ||
|
|
b0aa15b85b | ||
|
|
8834452005 | ||
|
|
79312ec17e | ||
|
|
753d040785 | ||
|
|
d096187121 | ||
|
|
1358a2751f | ||
|
|
652376d5b3 | ||
|
|
e14a40d164 | ||
|
|
cafbdc6174 | ||
|
|
40ea8e5cb4 | ||
|
|
d391f7c63d | ||
|
|
01487e8643 | ||
|
|
1719aeb5d2 | ||
|
|
e44f85ab5d | ||
|
|
80c8967c03 | ||
|
|
876915c6a1 | ||
|
|
4d127a6a46 | ||
|
|
e67726a839 | ||
|
|
be9e8a5340 | ||
|
|
06668fe36f | ||
|
|
1a89bb119d | ||
|
|
bd79a86b01 | ||
|
|
b2cdea89f5 | ||
|
|
9949620e45 | ||
|
|
29ab806ba6 | ||
|
|
c1d9c2e3b2 | ||
|
|
b436cdd69c | ||
|
|
1de01cb219 | ||
|
|
fd5e84d8e6 | ||
|
|
5ad959f728 | ||
|
|
af0a5af68c | ||
|
|
5ed03602e6 | ||
|
|
4b39e7d090 | ||
|
|
a39af74e4d | ||
|
|
53e7770fd1 | ||
|
|
7fa51274b9 | ||
|
|
821b7ac2b5 | ||
|
|
4e78cdbda6 | ||
|
|
7918702d81 | ||
|
|
1039ff757d | ||
|
|
330ed9959b | ||
|
|
6578fdad34 | ||
|
|
abad9ccee2 | ||
|
|
afdeae0362 | ||
|
|
8f99a3be7a | ||
|
|
979f5b2e7b | ||
|
|
b339e2c59e | ||
|
|
a50090c047 | ||
|
|
30093a30d3 | ||
|
|
92b911a7c0 | ||
|
|
163e61b805 | ||
|
|
5d366027d5 | ||
|
|
18052b1b57 | ||
|
|
c86b339f4f | ||
|
|
8cf5449fd9 | ||
|
|
8cdeecd144 | ||
|
|
3480143685 | ||
|
|
9f3116100a | ||
|
|
e6b4cdadc5 | ||
|
|
ae11b1005a | ||
|
|
7bdb63c235 | ||
|
|
0ad11db552 | ||
|
|
be113a79eb | ||
|
|
703ff0db40 | ||
|
|
131a9af96d | ||
|
|
9f32083fd9 | ||
|
|
f6eb5b3fa4 | ||
|
|
8ce607d540 | ||
|
|
042ea6250a | ||
|
|
6a7ab7a4d3 | ||
|
|
6d35589509 | ||
|
|
4a501d5aea | ||
|
|
59af29a2a0 | ||
|
|
249afa3d2e | ||
|
|
d0e2d0d885 | ||
|
|
35865af26a | ||
|
|
c9091dafe3 | ||
|
|
b6016a59f3 | ||
|
|
269168158d | ||
|
|
249af9e46c | ||
|
|
b1402be6d5 | ||
|
|
8da8d21484 | ||
|
|
f650e1150e | ||
|
|
338baa118e | ||
|
|
45cc4bb387 | ||
|
|
5e0c918e7b | ||
|
|
a92a9b0df5 | ||
|
|
831ce3cd26 | ||
|
|
075c1d5096 | ||
|
|
a650cb0e62 | ||
|
|
c27e9c11b6 | ||
|
|
adf91e8e2b | ||
|
|
f43f7a9777 | ||
|
|
5d636b506a | ||
|
|
edb89345ec | ||
|
|
201ecd476d | ||
|
|
5e38ddc11e | ||
|
|
2b9ab70dc0 | ||
|
|
f3f1c8c20e | ||
|
|
ba9e2c55e0 | ||
|
|
175027bed8 | ||
|
|
30f1e924b5 | ||
|
|
703f347ee8 | ||
|
|
7310129200 | ||
|
|
2aacf785b4 | ||
|
|
36e583d2b6 | ||
|
|
e0cceee495 | ||
|
|
8da4947343 | ||
|
|
17c42c34ad | ||
|
|
f258e9a659 | ||
|
|
1dbfde12af | ||
|
|
1ccdc3374a | ||
|
|
da30b2b421 |
1
.hgtags
1
.hgtags
@@ -494,3 +494,4 @@ fb8b3f4672774e15654958295558a1af1b576919 jdk-11+19
|
||||
fb8b3f4672774e15654958295558a1af1b576919 jdk-11+19
|
||||
36ca515343e00b021dcfc902e986d26ec994a2e5 jdk-11+19
|
||||
9816d7cc655e53ba081f938b656e31971b8f097a jdk-11+20
|
||||
1353ec839c82de926bfacd2c7976b6b652d4afb0 jdk-11.0.1+1
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
DEFAULT_VERSION_FEATURE=11
|
||||
DEFAULT_VERSION_INTERIM=0
|
||||
DEFAULT_VERSION_UPDATE=0
|
||||
DEFAULT_VERSION_UPDATE=1
|
||||
DEFAULT_VERSION_PATCH=0
|
||||
DEFAULT_VERSION_DATE=2018-09-25
|
||||
DEFAULT_VERSION_CLASSFILE_MAJOR=55 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`"
|
||||
|
||||
@@ -987,68 +987,68 @@ void LinkResolver::resolve_field(fieldDescriptor& fd,
|
||||
THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), field->as_C_string());
|
||||
}
|
||||
|
||||
if (!link_info.check_access())
|
||||
// Access checking may be turned off when calling from within the VM.
|
||||
return;
|
||||
|
||||
// check access
|
||||
// Access checking may be turned off when calling from within the VM.
|
||||
Klass* current_klass = link_info.current_klass();
|
||||
check_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK);
|
||||
if (link_info.check_access()) {
|
||||
|
||||
// check for errors
|
||||
if (is_static != fd.is_static()) {
|
||||
ResourceMark rm(THREAD);
|
||||
char msg[200];
|
||||
jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", resolved_klass->external_name(), fd.name()->as_C_string());
|
||||
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg);
|
||||
}
|
||||
// check access
|
||||
check_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK);
|
||||
|
||||
// A final field can be modified only
|
||||
// (1) by methods declared in the class declaring the field and
|
||||
// (2) by the <clinit> method (in case of a static field)
|
||||
// or by the <init> method (in case of an instance field).
|
||||
if (is_put && fd.access_flags().is_final()) {
|
||||
ResourceMark rm(THREAD);
|
||||
stringStream ss;
|
||||
|
||||
if (sel_klass != current_klass) {
|
||||
ss.print("Update to %s final field %s.%s attempted from a different class (%s) than the field's declaring class",
|
||||
is_static ? "static" : "non-static", resolved_klass->external_name(), fd.name()->as_C_string(),
|
||||
current_klass->external_name());
|
||||
THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string());
|
||||
// check for errors
|
||||
if (is_static != fd.is_static()) {
|
||||
ResourceMark rm(THREAD);
|
||||
char msg[200];
|
||||
jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", resolved_klass->external_name(), fd.name()->as_C_string());
|
||||
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg);
|
||||
}
|
||||
|
||||
if (fd.constants()->pool_holder()->major_version() >= 53) {
|
||||
methodHandle m = link_info.current_method();
|
||||
assert(!m.is_null(), "information about the current method must be available for 'put' bytecodes");
|
||||
bool is_initialized_static_final_update = (byte == Bytecodes::_putstatic &&
|
||||
fd.is_static() &&
|
||||
!m()->is_static_initializer());
|
||||
bool is_initialized_instance_final_update = ((byte == Bytecodes::_putfield || byte == Bytecodes::_nofast_putfield) &&
|
||||
!fd.is_static() &&
|
||||
!m->is_object_initializer());
|
||||
// A final field can be modified only
|
||||
// (1) by methods declared in the class declaring the field and
|
||||
// (2) by the <clinit> method (in case of a static field)
|
||||
// or by the <init> method (in case of an instance field).
|
||||
if (is_put && fd.access_flags().is_final()) {
|
||||
ResourceMark rm(THREAD);
|
||||
stringStream ss;
|
||||
|
||||
if (is_initialized_static_final_update || is_initialized_instance_final_update) {
|
||||
ss.print("Update to %s final field %s.%s attempted from a different method (%s) than the initializer method %s ",
|
||||
if (sel_klass != current_klass) {
|
||||
ss.print("Update to %s final field %s.%s attempted from a different class (%s) than the field's declaring class",
|
||||
is_static ? "static" : "non-static", resolved_klass->external_name(), fd.name()->as_C_string(),
|
||||
m()->name()->as_C_string(),
|
||||
is_static ? "<clinit>" : "<init>");
|
||||
current_klass->external_name());
|
||||
THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string());
|
||||
}
|
||||
|
||||
if (fd.constants()->pool_holder()->major_version() >= 53) {
|
||||
methodHandle m = link_info.current_method();
|
||||
assert(!m.is_null(), "information about the current method must be available for 'put' bytecodes");
|
||||
bool is_initialized_static_final_update = (byte == Bytecodes::_putstatic &&
|
||||
fd.is_static() &&
|
||||
!m()->is_static_initializer());
|
||||
bool is_initialized_instance_final_update = ((byte == Bytecodes::_putfield || byte == Bytecodes::_nofast_putfield) &&
|
||||
!fd.is_static() &&
|
||||
!m->is_object_initializer());
|
||||
|
||||
if (is_initialized_static_final_update || is_initialized_instance_final_update) {
|
||||
ss.print("Update to %s final field %s.%s attempted from a different method (%s) than the initializer method %s ",
|
||||
is_static ? "static" : "non-static", resolved_klass->external_name(), fd.name()->as_C_string(),
|
||||
m()->name()->as_C_string(),
|
||||
is_static ? "<clinit>" : "<init>");
|
||||
THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), ss.as_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// initialize resolved_klass if necessary
|
||||
// note 1: the klass which declared the field must be initialized (i.e, sel_klass)
|
||||
// according to the newest JVM spec (5.5, p.170) - was bug (gri 7/28/99)
|
||||
//
|
||||
// note 2: we don't want to force initialization if we are just checking
|
||||
// if the field access is legal; e.g., during compilation
|
||||
if (is_static && initialize_class) {
|
||||
sel_klass->initialize(CHECK);
|
||||
}
|
||||
}
|
||||
|
||||
// initialize resolved_klass if necessary
|
||||
// note 1: the klass which declared the field must be initialized (i.e, sel_klass)
|
||||
// according to the newest JVM spec (5.5, p.170) - was bug (gri 7/28/99)
|
||||
//
|
||||
// note 2: we don't want to force initialization if we are just checking
|
||||
// if the field access is legal; e.g., during compilation
|
||||
if (is_static && initialize_class) {
|
||||
sel_klass->initialize(CHECK);
|
||||
}
|
||||
|
||||
if (sel_klass != current_klass) {
|
||||
if ((sel_klass != current_klass) && (current_klass != NULL)) {
|
||||
check_field_loader_constraints(field, sig, current_klass, sel_klass, CHECK);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -29,6 +29,8 @@
|
||||
|
||||
package com.sun.crypto.provider;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import static com.sun.crypto.provider.AESConstants.AES_BLOCK_SIZE;
|
||||
|
||||
@@ -68,6 +70,15 @@ final class GCTR extends CounterMode {
|
||||
return "GCTR";
|
||||
}
|
||||
|
||||
// return the number of blocks until the lower 32 bits roll over
|
||||
private long blocksUntilRollover() {
|
||||
ByteBuffer buf = ByteBuffer.wrap(counter, counter.length - 4, 4);
|
||||
buf.order(ByteOrder.BIG_ENDIAN);
|
||||
long ctr32 = 0xFFFFFFFFL & buf.getInt();
|
||||
long blocksLeft = (1L << 32) - ctr32;
|
||||
return blocksLeft;
|
||||
}
|
||||
|
||||
// input must be multiples of 128-bit blocks when calling update
|
||||
int update(byte[] in, int inOfs, int inLen, byte[] out, int outOfs) {
|
||||
if (inLen - inOfs > in.length) {
|
||||
@@ -80,7 +91,25 @@ final class GCTR extends CounterMode {
|
||||
throw new RuntimeException("output buffer too small");
|
||||
}
|
||||
|
||||
return encrypt(in, inOfs, inLen, out, outOfs);
|
||||
long blocksLeft = blocksUntilRollover();
|
||||
int numOfCompleteBlocks = inLen / AES_BLOCK_SIZE;
|
||||
if (numOfCompleteBlocks >= blocksLeft) {
|
||||
// Counter Mode encryption cannot be used because counter will
|
||||
// roll over incorrectly. Use GCM-specific code instead.
|
||||
byte[] encryptedCntr = new byte[AES_BLOCK_SIZE];
|
||||
for (int i = 0; i < numOfCompleteBlocks; i++) {
|
||||
embeddedCipher.encryptBlock(counter, 0, encryptedCntr, 0);
|
||||
for (int n = 0; n < AES_BLOCK_SIZE; n++) {
|
||||
int index = (i * AES_BLOCK_SIZE + n);
|
||||
out[outOfs + index] =
|
||||
(byte) ((in[inOfs + index] ^ encryptedCntr[n]));
|
||||
}
|
||||
GaloisCounterMode.increment32(counter);
|
||||
}
|
||||
return inLen;
|
||||
} else {
|
||||
return encrypt(in, inOfs, inLen, out, outOfs);
|
||||
}
|
||||
}
|
||||
|
||||
// input can be arbitrary size when calling doFinal
|
||||
|
||||
@@ -69,10 +69,13 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
||||
*/
|
||||
int count;
|
||||
|
||||
private static final byte[] EMPTYVALUE = new byte[0];
|
||||
|
||||
/**
|
||||
* This no-arg constructor is necessary for serialization of subclasses.
|
||||
*/
|
||||
AbstractStringBuilder() {
|
||||
value = EMPTYVALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -35,6 +35,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.ObjectStreamField;
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectInputStream.GetField;
|
||||
import java.io.ObjectOutputStream;
|
||||
@@ -1728,8 +1729,11 @@ class InetAddress implements java.io.Serializable {
|
||||
}
|
||||
GetField gf = s.readFields();
|
||||
String host = (String)gf.get("hostName", null);
|
||||
int address= gf.get("address", 0);
|
||||
int family= gf.get("family", 0);
|
||||
int address = gf.get("address", 0);
|
||||
int family = gf.get("family", 0);
|
||||
if (family != IPv4 && family != IPv6) {
|
||||
throw new InvalidObjectException("invalid address family type: " + family);
|
||||
}
|
||||
InetAddressHolder h = new InetAddressHolder(host, address, family);
|
||||
UNSAFE.putObject(this, FIELDS_OFFSET, h);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -321,8 +321,20 @@ public final class NetworkInterface {
|
||||
if (addr == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (!(addr instanceof Inet4Address || addr instanceof Inet6Address)) {
|
||||
throw new IllegalArgumentException ("invalid address type");
|
||||
if (addr instanceof Inet4Address) {
|
||||
Inet4Address inet4Address = (Inet4Address) addr;
|
||||
if (inet4Address.holder.family != InetAddress.IPv4) {
|
||||
throw new IllegalArgumentException("invalid family type: "
|
||||
+ inet4Address.holder.family);
|
||||
}
|
||||
} else if (addr instanceof Inet6Address) {
|
||||
Inet6Address inet6Address = (Inet6Address) addr;
|
||||
if (inet6Address.holder.family != InetAddress.IPv6) {
|
||||
throw new IllegalArgumentException("invalid family type: "
|
||||
+ inet6Address.holder.family);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("invalid address type: " + addr);
|
||||
}
|
||||
return getByInetAddress0(addr);
|
||||
}
|
||||
|
||||
@@ -570,13 +570,13 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
* @spec JPMS
|
||||
*/
|
||||
protected Package definePackage(String name, Manifest man, URL url) {
|
||||
String path = name.replace('.', '/').concat("/");
|
||||
String specTitle = null, specVersion = null, specVendor = null;
|
||||
String implTitle = null, implVersion = null, implVendor = null;
|
||||
String sealed = null;
|
||||
URL sealBase = null;
|
||||
|
||||
Attributes attr = man.getAttributes(path);
|
||||
Attributes attr = SharedSecrets.javaUtilJarAccess()
|
||||
.getTrustedAttributes(man, name.replace('.', '/').concat("/"));
|
||||
if (attr != null) {
|
||||
specTitle = attr.getValue(Name.SPECIFICATION_TITLE);
|
||||
specVersion = attr.getValue(Name.SPECIFICATION_VERSION);
|
||||
@@ -620,10 +620,12 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
/*
|
||||
* Returns true if the specified package name is sealed according to the
|
||||
* given manifest.
|
||||
*
|
||||
* @throws SecurityException if the package name is untrusted in the manifest
|
||||
*/
|
||||
private boolean isSealed(String name, Manifest man) {
|
||||
String path = name.replace('.', '/').concat("/");
|
||||
Attributes attr = man.getAttributes(path);
|
||||
Attributes attr = SharedSecrets.javaUtilJarAccess()
|
||||
.getTrustedAttributes(man, name.replace('.', '/').concat("/"));
|
||||
String sealed = null;
|
||||
if (attr != null) {
|
||||
sealed = attr.getValue(Name.SEALED);
|
||||
|
||||
@@ -417,10 +417,10 @@ class JarFile extends ZipFile {
|
||||
if (manEntry != null) {
|
||||
if (verify) {
|
||||
byte[] b = getBytes(manEntry);
|
||||
man = new Manifest(new ByteArrayInputStream(b));
|
||||
if (!jvInitialized) {
|
||||
jv = new JarVerifier(b);
|
||||
}
|
||||
man = new Manifest(jv, new ByteArrayInputStream(b));
|
||||
} else {
|
||||
man = new Manifest(super.getInputStream(manEntry));
|
||||
}
|
||||
@@ -1010,29 +1010,13 @@ class JarFile extends ZipFile {
|
||||
int i = match(MULTIRELEASE_CHARS, b, MULTIRELEASE_LASTOCC,
|
||||
MULTIRELEASE_OPTOSFT);
|
||||
if (i != -1) {
|
||||
i += MULTIRELEASE_CHARS.length;
|
||||
if (i < b.length) {
|
||||
byte c = b[i++];
|
||||
// Check that the value is followed by a newline
|
||||
// and does not have a continuation
|
||||
if (c == '\n' &&
|
||||
(i == b.length || b[i] != ' ')) {
|
||||
isMultiRelease = true;
|
||||
} else if (c == '\r') {
|
||||
if (i == b.length) {
|
||||
isMultiRelease = true;
|
||||
} else {
|
||||
c = b[i++];
|
||||
if (c == '\n') {
|
||||
if (i == b.length || b[i] != ' ') {
|
||||
isMultiRelease = true;
|
||||
}
|
||||
} else if (c != ' ') {
|
||||
isMultiRelease = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Read the main attributes of the manifest
|
||||
byte[] lbuf = new byte[512];
|
||||
Attributes attr = new Attributes();
|
||||
attr.read(new Manifest.FastInputStream(
|
||||
new ByteArrayInputStream(b)), lbuf);
|
||||
isMultiRelease = Boolean.parseBoolean(
|
||||
attr.getValue(Attributes.Name.MULTI_RELEASE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -858,4 +858,24 @@ class JarVerifier {
|
||||
static CodeSource getUnsignedCS(URL url) {
|
||||
return new VerifierCodeSource(null, url, (java.security.cert.Certificate[]) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the name is trusted. Used by
|
||||
* {@link Manifest#getTrustedAttributes(String)}.
|
||||
*/
|
||||
boolean isTrustedManifestEntry(String name) {
|
||||
// How many signers? MANIFEST.MF is always verified
|
||||
CodeSigner[] forMan = verifiedSigners.get(JarFile.MANIFEST_NAME);
|
||||
if (forMan == null) {
|
||||
return true;
|
||||
}
|
||||
// Check sigFileSigners first, because we are mainly dealing with
|
||||
// non-file entries which will stay in sigFileSigners forever.
|
||||
CodeSigner[] forName = sigFileSigners.get(name);
|
||||
if (forName == null) {
|
||||
forName = verifiedSigners.get(name);
|
||||
}
|
||||
// Returns trusted if all signers sign the entry
|
||||
return forName != null && forName.length == forMan.length;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -60,4 +60,9 @@ class JavaUtilJarAccessImpl implements JavaUtilJarAccess {
|
||||
public List<Object> getManifestDigests(JarFile jar) {
|
||||
return jar.getManifestDigests();
|
||||
}
|
||||
|
||||
public Attributes getTrustedAttributes(Manifest man, String name) {
|
||||
return man.getTrustedAttributes(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* The Manifest class is used to maintain Manifest entry names and their
|
||||
@@ -48,15 +47,19 @@ import java.util.Iterator;
|
||||
*/
|
||||
public class Manifest implements Cloneable {
|
||||
// manifest main attributes
|
||||
private Attributes attr = new Attributes();
|
||||
private final Attributes attr = new Attributes();
|
||||
|
||||
// manifest entries
|
||||
private Map<String, Attributes> entries = new HashMap<>();
|
||||
private final Map<String, Attributes> entries = new HashMap<>();
|
||||
|
||||
// associated JarVerifier, not null when called by JarFile::getManifest.
|
||||
private final JarVerifier jv;
|
||||
|
||||
/**
|
||||
* Constructs a new, empty Manifest.
|
||||
*/
|
||||
public Manifest() {
|
||||
jv = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +69,16 @@ public class Manifest implements Cloneable {
|
||||
* @throws IOException if an I/O error has occurred
|
||||
*/
|
||||
public Manifest(InputStream is) throws IOException {
|
||||
this(null, is);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new Manifest from the specified input stream
|
||||
* and associates it with a JarVerifier.
|
||||
*/
|
||||
Manifest(JarVerifier jv, InputStream is) throws IOException {
|
||||
read(is);
|
||||
this.jv = jv;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,6 +89,7 @@ public class Manifest implements Cloneable {
|
||||
public Manifest(Manifest man) {
|
||||
attr.putAll(man.getMainAttributes());
|
||||
entries.putAll(man.getEntries());
|
||||
jv = man.jv;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,6 +139,23 @@ public class Manifest implements Cloneable {
|
||||
return getEntries().get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Attributes for the specified entry name, if trusted.
|
||||
*
|
||||
* @param name entry name
|
||||
* @return returns the same result as {@link #getAttributes(String)}
|
||||
* @throws SecurityException if the associated jar is signed but this entry
|
||||
* has been modified after signing (i.e. the section in the manifest
|
||||
* does not exist in SF files of all signers).
|
||||
*/
|
||||
Attributes getTrustedAttributes(String name) {
|
||||
Attributes result = getAttributes(name);
|
||||
if (result != null && jv != null && ! jv.isTrustedManifestEntry(name)) {
|
||||
throw new SecurityException("Untrusted manifest entry: " + name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the main Attributes as well as the entries in this Manifest.
|
||||
*/
|
||||
|
||||
@@ -106,7 +106,7 @@ public class PatternSyntaxException
|
||||
}
|
||||
sb.append(System.lineSeparator());
|
||||
sb.append(pattern);
|
||||
if (index >= 0) {
|
||||
if (index >= 0 && pattern != null && index < pattern.length()) {
|
||||
sb.append(System.lineSeparator());
|
||||
for (int i = 0; i < index; i++) sb.append(' ');
|
||||
sb.append('^');
|
||||
|
||||
@@ -2739,7 +2739,7 @@ public class Cipher {
|
||||
|
||||
// Input sanity check
|
||||
if ((src == null) || (offset < 0) || (len < 0)
|
||||
|| ((len + offset) > src.length)) {
|
||||
|| (len > (src.length - offset))) {
|
||||
throw new IllegalArgumentException("Bad arguments");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -50,6 +50,13 @@ import javax.crypto.IllegalBlockSizeException;
|
||||
* that are not thrown by its ancestor classes. In particular, the
|
||||
* <code>skip</code> method skips, and the <code>available</code>
|
||||
* method counts only data that have been processed by the encapsulated Cipher.
|
||||
* This class may catch BadPaddingException and other exceptions thrown by
|
||||
* failed integrity checks during decryption. These exceptions are not
|
||||
* re-thrown, so the client may not be informed that integrity checks
|
||||
* failed. Because of this behavior, this class may not be suitable
|
||||
* for use with decryption in an authenticated mode of operation (e.g. GCM).
|
||||
* Applications that require authenticated encryption can use the Cipher API
|
||||
* directly as an alternative to using this class.
|
||||
*
|
||||
* <p> It is crucial for a programmer using this class not to use
|
||||
* methods that are not defined or overriden in this class (such as a
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -120,7 +120,7 @@ public class GCMParameterSpec implements AlgorithmParameterSpec {
|
||||
|
||||
// Input sanity check
|
||||
if ((src == null) ||(len < 0) || (offset < 0)
|
||||
|| ((len + offset) > src.length)) {
|
||||
|| (len > (src.length - offset))) {
|
||||
throw new IllegalArgumentException("Invalid buffer arguments");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -60,6 +60,7 @@ import java.util.jar.Attributes;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.module.ModulePatcher.PatchedModuleReader;
|
||||
import jdk.internal.module.Resources;
|
||||
@@ -862,7 +863,8 @@ public class BuiltinClassLoader
|
||||
* Manifest are used to get the package version and sealing information.
|
||||
*
|
||||
* @throws IllegalArgumentException if the package name duplicates an
|
||||
* existing package either in this class loader or one of its ancestors
|
||||
* existing package either in this class loader or one of its ancestors
|
||||
* @throws SecurityException if the package name is untrusted in the manifest
|
||||
*/
|
||||
private Package definePackage(String pn, Manifest man, URL url) {
|
||||
String specTitle = null;
|
||||
@@ -875,7 +877,8 @@ public class BuiltinClassLoader
|
||||
URL sealBase = null;
|
||||
|
||||
if (man != null) {
|
||||
Attributes attr = man.getAttributes(pn.replace('.', '/').concat("/"));
|
||||
Attributes attr = SharedSecrets.javaUtilJarAccess()
|
||||
.getTrustedAttributes(man, pn.replace('.', '/').concat("/"));
|
||||
if (attr != null) {
|
||||
specTitle = attr.getValue(Attributes.Name.SPECIFICATION_TITLE);
|
||||
specVersion = attr.getValue(Attributes.Name.SPECIFICATION_VERSION);
|
||||
@@ -921,10 +924,12 @@ public class BuiltinClassLoader
|
||||
/**
|
||||
* Returns {@code true} if the specified package name is sealed according to
|
||||
* the given manifest.
|
||||
*
|
||||
* @throws SecurityException if the package name is untrusted in the manifest
|
||||
*/
|
||||
private boolean isSealed(String pn, Manifest man) {
|
||||
String path = pn.replace('.', '/').concat("/");
|
||||
Attributes attr = man.getAttributes(path);
|
||||
Attributes attr = SharedSecrets.javaUtilJarAccess()
|
||||
.getTrustedAttributes(man, pn.replace('.', '/').concat("/"));
|
||||
String sealed = null;
|
||||
if (attr != null)
|
||||
sealed = attr.getValue(Attributes.Name.SEALED);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -34,6 +34,7 @@ import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.JarURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLStreamHandler;
|
||||
@@ -88,6 +89,8 @@ public class URLClassPath {
|
||||
private static final boolean DEBUG;
|
||||
private static final boolean DISABLE_JAR_CHECKING;
|
||||
private static final boolean DISABLE_ACC_CHECKING;
|
||||
private static final boolean DISABLE_CP_URL_CHECK;
|
||||
private static final boolean DEBUG_CP_URL_CHECK;
|
||||
|
||||
static {
|
||||
Properties props = GetPropertyAction.privilegedGetProperties();
|
||||
@@ -98,6 +101,12 @@ public class URLClassPath {
|
||||
|
||||
p = props.getProperty("jdk.net.URLClassPath.disableRestrictedPermissions");
|
||||
DISABLE_ACC_CHECKING = p != null ? p.equals("true") || p.equals("") : false;
|
||||
|
||||
// This property will be removed in a later release
|
||||
p = props.getProperty("jdk.net.URLClassPath.disableClassPathURLCheck");
|
||||
|
||||
DISABLE_CP_URL_CHECK = p != null ? p.equals("true") || p.isEmpty() : false;
|
||||
DEBUG_CP_URL_CHECK = "debug".equals(p);
|
||||
}
|
||||
|
||||
/* The original search path of URLs. */
|
||||
@@ -1081,11 +1090,51 @@ public class URLClassPath {
|
||||
int i = 0;
|
||||
while (st.hasMoreTokens()) {
|
||||
String path = st.nextToken();
|
||||
urls[i] = new URL(base, path);
|
||||
i++;
|
||||
URL url = DISABLE_CP_URL_CHECK ? new URL(base, path) : safeResolve(base, path);
|
||||
if (url != null) {
|
||||
urls[i] = url;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (i == 0) {
|
||||
urls = null;
|
||||
} else if (i != urls.length) {
|
||||
// Truncate nulls from end of array
|
||||
urls = Arrays.copyOf(urls, i);
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a URL for the given path resolved against the base URL, or
|
||||
* null if the resulting URL is invalid.
|
||||
*/
|
||||
static URL safeResolve(URL base, String path) {
|
||||
String child = path.replace(File.separatorChar, '/');
|
||||
try {
|
||||
if (!URI.create(child).isAbsolute()) {
|
||||
URL url = new URL(base, child);
|
||||
if (base.getProtocol().equalsIgnoreCase("file")) {
|
||||
return url;
|
||||
} else {
|
||||
String bp = base.getPath();
|
||||
String urlp = url.getPath();
|
||||
int pos = bp.lastIndexOf('/');
|
||||
if (pos == -1) {
|
||||
pos = bp.length() - 1;
|
||||
}
|
||||
if (urlp.regionMatches(0, bp, 0, pos + 1)
|
||||
&& urlp.indexOf("..", pos) == -1) {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (MalformedURLException | IllegalArgumentException e) {}
|
||||
if (DEBUG_CP_URL_CHECK) {
|
||||
System.err.println("Class-Path entry: \"" + path + "\" ignored in JAR file " + base);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -30,8 +30,10 @@ import java.net.URL;
|
||||
import java.security.CodeSource;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
public interface JavaUtilJarAccess {
|
||||
public boolean jarFileHasClassPathAttribute(JarFile jar) throws IOException;
|
||||
@@ -41,4 +43,5 @@ public interface JavaUtilJarAccess {
|
||||
public Enumeration<JarEntry> entries2(JarFile jar);
|
||||
public void setEagerValidation(JarFile jar, boolean eager);
|
||||
public List<Object> getManifestDigests(JarFile jar);
|
||||
public Attributes getTrustedAttributes(Manifest man, String name);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -87,6 +87,9 @@ public class ReflectionFactory {
|
||||
private static boolean noInflation = false;
|
||||
private static int inflationThreshold = 15;
|
||||
|
||||
// true if deserialization constructor checking is disabled
|
||||
private static boolean disableSerialConstructorChecks = false;
|
||||
|
||||
private ReflectionFactory() {
|
||||
}
|
||||
|
||||
@@ -424,10 +427,64 @@ public class ReflectionFactory {
|
||||
return generateConstructor(cl, constructorToCall);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a class, determines whether its superclass has
|
||||
* any constructors that are accessible from the class.
|
||||
* This is a special purpose method intended to do access
|
||||
* checking for a serializable class and its superclasses
|
||||
* up to, but not including, the first non-serializable
|
||||
* superclass. This also implies that the superclass is
|
||||
* always non-null, because a serializable class must be a
|
||||
* class (not an interface) and Object is not serializable.
|
||||
*
|
||||
* @param cl the class from which access is checked
|
||||
* @return whether the superclass has a constructor accessible from cl
|
||||
*/
|
||||
private boolean superHasAccessibleConstructor(Class<?> cl) {
|
||||
Class<?> superCl = cl.getSuperclass();
|
||||
assert Serializable.class.isAssignableFrom(cl);
|
||||
assert superCl != null;
|
||||
if (packageEquals(cl, superCl)) {
|
||||
// accessible if any non-private constructor is found
|
||||
for (Constructor<?> ctor : superCl.getDeclaredConstructors()) {
|
||||
if ((ctor.getModifiers() & Modifier.PRIVATE) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
// sanity check to ensure the parent is protected or public
|
||||
if ((superCl.getModifiers() & (Modifier.PROTECTED | Modifier.PUBLIC)) == 0) {
|
||||
return false;
|
||||
}
|
||||
// accessible if any constructor is protected or public
|
||||
for (Constructor<?> ctor : superCl.getDeclaredConstructors()) {
|
||||
if ((ctor.getModifiers() & (Modifier.PROTECTED | Modifier.PUBLIC)) != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a constructor that allocates an instance of cl and that then initializes
|
||||
* the instance by calling the no-arg constructor of its first non-serializable
|
||||
* superclass. This is specified in the Serialization Specification, section 3.1,
|
||||
* in step 11 of the deserialization process. If cl is not serializable, returns
|
||||
* cl's no-arg constructor. If no accessible constructor is found, or if the
|
||||
* class hierarchy is somehow malformed (e.g., a serializable class has no
|
||||
* superclass), null is returned.
|
||||
*
|
||||
* @param cl the class for which a constructor is to be found
|
||||
* @return the generated constructor, or null if none is available
|
||||
*/
|
||||
public final Constructor<?> newConstructorForSerialization(Class<?> cl) {
|
||||
Class<?> initCl = cl;
|
||||
while (Serializable.class.isAssignableFrom(initCl)) {
|
||||
if ((initCl = initCl.getSuperclass()) == null) {
|
||||
Class<?> prev = initCl;
|
||||
if ((initCl = initCl.getSuperclass()) == null ||
|
||||
(!disableSerialConstructorChecks && !superHasAccessibleConstructor(prev))) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -653,6 +710,9 @@ public class ReflectionFactory {
|
||||
}
|
||||
}
|
||||
|
||||
disableSerialConstructorChecks =
|
||||
"true".equals(props.getProperty("jdk.disableSerialConstructorChecks"));
|
||||
|
||||
initted = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -297,6 +297,22 @@ JNU_NotifyAll(JNIEnv *env, jobject object);
|
||||
} \
|
||||
} while (0) \
|
||||
|
||||
#define CHECK_NULL_THROW_NPE(env, x, msg) \
|
||||
do { \
|
||||
if ((x) == NULL) { \
|
||||
JNU_ThrowNullPointerException((env), (msg));\
|
||||
return; \
|
||||
} \
|
||||
} while(0) \
|
||||
|
||||
#define CHECK_NULL_THROW_NPE_RETURN(env, x, msg, z)\
|
||||
do { \
|
||||
if ((x) == NULL) { \
|
||||
JNU_ThrowNullPointerException((env), (msg));\
|
||||
return (z); \
|
||||
} \
|
||||
} while(0) \
|
||||
|
||||
#define CHECK_NULL_RETURN(x, y) \
|
||||
do { \
|
||||
if ((x) == NULL) { \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -171,32 +171,38 @@ jboolean setInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *address) {
|
||||
|
||||
void setInetAddress_addr(JNIEnv *env, jobject iaObj, int address) {
|
||||
jobject holder = (*env)->GetObjectField(env, iaObj, ia_holderID);
|
||||
CHECK_NULL_THROW_NPE(env, holder, "InetAddress holder is null");
|
||||
(*env)->SetIntField(env, holder, iac_addressID, address);
|
||||
}
|
||||
|
||||
void setInetAddress_family(JNIEnv *env, jobject iaObj, int family) {
|
||||
jobject holder = (*env)->GetObjectField(env, iaObj, ia_holderID);
|
||||
CHECK_NULL_THROW_NPE(env, holder, "InetAddress holder is null");
|
||||
(*env)->SetIntField(env, holder, iac_familyID, family);
|
||||
}
|
||||
|
||||
void setInetAddress_hostName(JNIEnv *env, jobject iaObj, jobject host) {
|
||||
jobject holder = (*env)->GetObjectField(env, iaObj, ia_holderID);
|
||||
CHECK_NULL_THROW_NPE(env, holder, "InetAddress holder is null");
|
||||
(*env)->SetObjectField(env, holder, iac_hostNameID, host);
|
||||
(*env)->SetObjectField(env, holder, iac_origHostNameID, host);
|
||||
}
|
||||
|
||||
int getInetAddress_addr(JNIEnv *env, jobject iaObj) {
|
||||
jobject holder = (*env)->GetObjectField(env, iaObj, ia_holderID);
|
||||
CHECK_NULL_THROW_NPE_RETURN(env, holder, "InetAddress holder is null", -1);
|
||||
return (*env)->GetIntField(env, holder, iac_addressID);
|
||||
}
|
||||
|
||||
int getInetAddress_family(JNIEnv *env, jobject iaObj) {
|
||||
jobject holder = (*env)->GetObjectField(env, iaObj, ia_holderID);
|
||||
CHECK_NULL_THROW_NPE_RETURN(env, holder, "InetAddress holder is null", -1);
|
||||
return (*env)->GetIntField(env, holder, iac_familyID);
|
||||
}
|
||||
|
||||
jobject getInetAddress_hostName(JNIEnv *env, jobject iaObj) {
|
||||
jobject holder = (*env)->GetObjectField(env, iaObj, ia_holderID);
|
||||
CHECK_NULL_THROW_NPE_RETURN(env, holder, "InetAddress holder is null", NULL);
|
||||
return (*env)->GetObjectField(env, holder, iac_hostNameID);
|
||||
}
|
||||
|
||||
@@ -211,7 +217,9 @@ NET_SockaddrToInetAddress(JNIEnv *env, SOCKETADDRESS *sa, int *port) {
|
||||
CHECK_NULL_RETURN(iaObj, NULL);
|
||||
address = NET_IPv4MappedToIPv4(caddr);
|
||||
setInetAddress_addr(env, iaObj, address);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
|
||||
setInetAddress_family(env, iaObj, java_net_InetAddress_IPv4);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
|
||||
} else {
|
||||
jboolean ret;
|
||||
iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
|
||||
@@ -220,6 +228,7 @@ NET_SockaddrToInetAddress(JNIEnv *env, SOCKETADDRESS *sa, int *port) {
|
||||
if (ret == JNI_FALSE)
|
||||
return NULL;
|
||||
setInetAddress_family(env, iaObj, java_net_InetAddress_IPv6);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
|
||||
setInet6Address_scopeid(env, iaObj, sa->sa6.sin6_scope_id);
|
||||
}
|
||||
*port = ntohs(sa->sa6.sin6_port);
|
||||
@@ -227,7 +236,9 @@ NET_SockaddrToInetAddress(JNIEnv *env, SOCKETADDRESS *sa, int *port) {
|
||||
iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
|
||||
CHECK_NULL_RETURN(iaObj, NULL);
|
||||
setInetAddress_family(env, iaObj, java_net_InetAddress_IPv4);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
|
||||
setInetAddress_addr(env, iaObj, ntohl(sa->sa4.sin_addr.s_addr));
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
|
||||
*port = ntohs(sa->sa4.sin_port);
|
||||
}
|
||||
return iaObj;
|
||||
@@ -238,6 +249,7 @@ NET_SockaddrEqualsInetAddress(JNIEnv *env, SOCKETADDRESS *sa, jobject iaObj)
|
||||
{
|
||||
jint family = getInetAddress_family(env, iaObj) ==
|
||||
java_net_InetAddress_IPv4 ? AF_INET : AF_INET6;
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
|
||||
if (sa->sa.sa_family == AF_INET6) {
|
||||
jbyte *caddrNew = (jbyte *)&sa->sa6.sin6_addr;
|
||||
if (NET_IsIPv4Mapped(caddrNew)) {
|
||||
@@ -247,6 +259,7 @@ NET_SockaddrEqualsInetAddress(JNIEnv *env, SOCKETADDRESS *sa, jobject iaObj)
|
||||
}
|
||||
addrNew = NET_IPv4MappedToIPv4(caddrNew);
|
||||
addrCur = getInetAddress_addr(env, iaObj);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
|
||||
if (addrNew == addrCur) {
|
||||
return JNI_TRUE;
|
||||
} else {
|
||||
@@ -273,6 +286,7 @@ NET_SockaddrEqualsInetAddress(JNIEnv *env, SOCKETADDRESS *sa, jobject iaObj)
|
||||
}
|
||||
addrNew = ntohl(sa->sa4.sin_addr.s_addr);
|
||||
addrCur = getInetAddress_addr(env, iaObj);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
|
||||
if (addrNew == addrCur) {
|
||||
return JNI_TRUE;
|
||||
} else {
|
||||
|
||||
@@ -193,7 +193,11 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
|
||||
}
|
||||
setInetAddress_addr(env, iaObj, ntohl(((struct sockaddr_in *)
|
||||
(iterator->ai_addr))->sin_addr.s_addr));
|
||||
if ((*env)->ExceptionCheck(env))
|
||||
goto cleanupAndReturn;
|
||||
setInetAddress_hostName(env, iaObj, host);
|
||||
if ((*env)->ExceptionCheck(env))
|
||||
goto cleanupAndReturn;
|
||||
(*env)->SetObjectArrayElement(env, ret, i++, iaObj);
|
||||
iterator = iterator->ai_next;
|
||||
}
|
||||
|
||||
@@ -198,6 +198,8 @@ lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6)
|
||||
return NULL;
|
||||
}
|
||||
setInetAddress_hostName(env, o, name);
|
||||
if ((*env)->ExceptionCheck(env))
|
||||
goto done;
|
||||
(*env)->SetObjectArrayElement(env, result, index, o);
|
||||
(*env)->DeleteLocalRef(env, o);
|
||||
}
|
||||
@@ -355,7 +357,11 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
|
||||
goto cleanupAndReturn;
|
||||
}
|
||||
setInetAddress_addr(env, iaObj, ntohl(((struct sockaddr_in*)iterator->ai_addr)->sin_addr.s_addr));
|
||||
if ((*env)->ExceptionCheck(env))
|
||||
goto cleanupAndReturn;
|
||||
setInetAddress_hostName(env, iaObj, host);
|
||||
if ((*env)->ExceptionCheck(env))
|
||||
goto cleanupAndReturn;
|
||||
(*env)->SetObjectArrayElement(env, ret, (inetIndex | originalIndex), iaObj);
|
||||
inetIndex++;
|
||||
} else if (iterator->ai_family == AF_INET6) {
|
||||
@@ -376,6 +382,8 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
|
||||
setInet6Address_scopeid(env, iaObj, scope);
|
||||
}
|
||||
setInetAddress_hostName(env, iaObj, host);
|
||||
if ((*env)->ExceptionCheck(env))
|
||||
goto cleanupAndReturn;
|
||||
(*env)->SetObjectArrayElement(env, ret, (inet6Index | originalIndex), iaObj);
|
||||
inet6Index++;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -329,11 +329,18 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0
|
||||
(JNIEnv *env, jclass cls, jobject iaObj)
|
||||
{
|
||||
netif *ifs, *curr;
|
||||
int family = (getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4) ?
|
||||
AF_INET : AF_INET6;
|
||||
jobject obj = NULL;
|
||||
jboolean match = JNI_FALSE;
|
||||
int family = getInetAddress_family(env, iaObj);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
|
||||
|
||||
if (family == java_net_InetAddress_IPv4) {
|
||||
family = AF_INET;
|
||||
} else if (family == java_net_InetAddress_IPv6) {
|
||||
family = AF_INET6;
|
||||
} else {
|
||||
return NULL; // Invalid family
|
||||
}
|
||||
ifs = enumInterfaces(env);
|
||||
if (ifs == NULL) {
|
||||
return NULL;
|
||||
@@ -351,7 +358,9 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0
|
||||
int address1 = htonl(
|
||||
((struct sockaddr_in *)addrP->addr)->sin_addr.s_addr);
|
||||
int address2 = getInetAddress_addr(env, iaObj);
|
||||
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
goto cleanup;
|
||||
}
|
||||
if (address1 == address2) {
|
||||
match = JNI_TRUE;
|
||||
break;
|
||||
@@ -397,6 +406,7 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0
|
||||
obj = createNetworkInterface(env, curr);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
// release the interface list
|
||||
freeif(ifs);
|
||||
|
||||
@@ -698,6 +708,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) {
|
||||
if (iaObj) {
|
||||
setInetAddress_addr(env, iaObj, htonl(
|
||||
((struct sockaddr_in*)addrP->addr)->sin_addr.s_addr));
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
@@ -710,6 +721,7 @@ static jobject createNetworkInterface(JNIEnv *env, netif *ifs) {
|
||||
if (ia2Obj) {
|
||||
setInetAddress_addr(env, ia2Obj, htonl(
|
||||
((struct sockaddr_in*)addrP->brdcast)->sin_addr.s_addr));
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
|
||||
(*env)->SetObjectField(env, ibObj, ni_ib4broadcastID, ia2Obj);
|
||||
} else {
|
||||
return NULL;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -531,9 +531,12 @@ Java_java_net_PlainDatagramSocketImpl_peek(JNIEnv *env, jobject this,
|
||||
iaObj = NET_SockaddrToInetAddress(env, &rmtaddr, &port);
|
||||
family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ?
|
||||
AF_INET : AF_INET6;
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, -1);
|
||||
if (family == AF_INET) { /* this API can't handle IPV6 addresses */
|
||||
int address = getInetAddress_addr(env, iaObj);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, -1);
|
||||
setInetAddress_addr(env, addressObj, address);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, -1);
|
||||
}
|
||||
return port;
|
||||
}
|
||||
@@ -1014,6 +1017,7 @@ static void mcast_set_if_by_if_v4(JNIEnv *env, jobject this, int fd, jobject val
|
||||
struct in_addr in;
|
||||
jobjectArray addrArray;
|
||||
jsize len;
|
||||
jint family;
|
||||
jobject addr;
|
||||
int i;
|
||||
|
||||
@@ -1044,8 +1048,11 @@ static void mcast_set_if_by_if_v4(JNIEnv *env, jobject this, int fd, jobject val
|
||||
in.s_addr = 0;
|
||||
for (i = 0; i < len; i++) {
|
||||
addr = (*env)->GetObjectArrayElement(env, addrArray, i);
|
||||
if (getInetAddress_family(env, addr) == java_net_InetAddress_IPv4) {
|
||||
family = getInetAddress_family(env, addr);
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
if (family == java_net_InetAddress_IPv4) {
|
||||
in.s_addr = htonl(getInetAddress_addr(env, addr));
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1095,7 +1102,7 @@ static void mcast_set_if_by_addr_v4(JNIEnv *env, jobject this, int fd, jobject v
|
||||
struct in_addr in;
|
||||
|
||||
in.s_addr = htonl( getInetAddress_addr(env, value) );
|
||||
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
|
||||
(const char*)&in, sizeof(in)) < 0) {
|
||||
JNU_ThrowByNameWithMessageAndLastError
|
||||
@@ -1458,6 +1465,7 @@ jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, jint opt) {
|
||||
CHECK_NULL_RETURN(addr, NULL);
|
||||
|
||||
setInetAddress_addr(env, addr, ntohl(in.s_addr));
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
|
||||
|
||||
/*
|
||||
* For IP_MULTICAST_IF return InetAddress
|
||||
@@ -1890,6 +1898,7 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
|
||||
|
||||
jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
|
||||
jint fd;
|
||||
jint family;
|
||||
jint ipv6_join_leave;
|
||||
|
||||
if (IS_NULL(fdObj)) {
|
||||
@@ -1910,7 +1919,9 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
|
||||
ipv6_join_leave = ipv6_available();
|
||||
|
||||
#ifdef __linux__
|
||||
if (getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4) {
|
||||
family = getInetAddress_family(env, iaObj);
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
if (family == java_net_InetAddress_IPv4) {
|
||||
ipv6_join_leave = JNI_FALSE;
|
||||
}
|
||||
#endif
|
||||
@@ -1951,6 +1962,7 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
|
||||
}
|
||||
|
||||
mname.imr_multiaddr.s_addr = htonl(getInetAddress_addr(env, iaObj));
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
mname.imr_address.s_addr = 0;
|
||||
mname.imr_ifindex = (*env)->GetIntField(env, niObj, ni_indexID);
|
||||
mname_len = sizeof(struct ip_mreqn);
|
||||
@@ -1969,11 +1981,14 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
|
||||
addr = (*env)->GetObjectArrayElement(env, addrArray, 0);
|
||||
|
||||
mname.imr_multiaddr.s_addr = htonl(getInetAddress_addr(env, iaObj));
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
#ifdef __linux__
|
||||
mname.imr_address.s_addr = htonl(getInetAddress_addr(env, addr));
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
mname.imr_ifindex = 0;
|
||||
#else
|
||||
mname.imr_interface.s_addr = htonl(getInetAddress_addr(env, addr));
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
#endif
|
||||
mname_len = sizeof(struct ip_mreq);
|
||||
}
|
||||
@@ -2009,6 +2024,7 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
|
||||
}
|
||||
|
||||
mname.imr_multiaddr.s_addr = htonl(getInetAddress_addr(env, iaObj));
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
mname.imr_address.s_addr = 0 ;
|
||||
mname.imr_ifindex = index;
|
||||
mname_len = sizeof(struct ip_mreqn);
|
||||
@@ -2031,6 +2047,7 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
|
||||
mname.imr_interface.s_addr = in.s_addr;
|
||||
#endif
|
||||
mname.imr_multiaddr.s_addr = htonl(getInetAddress_addr(env, iaObj));
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
mname_len = sizeof(struct ip_mreq);
|
||||
}
|
||||
}
|
||||
@@ -2097,10 +2114,11 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
|
||||
jint address;
|
||||
family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ?
|
||||
AF_INET : AF_INET6;
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
if (family == AF_INET) { /* will convert to IPv4-mapped address */
|
||||
memset((char *) caddr, 0, 16);
|
||||
address = getInetAddress_addr(env, iaObj);
|
||||
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
caddr[10] = 0xff;
|
||||
caddr[11] = 0xff;
|
||||
|
||||
|
||||
@@ -764,6 +764,7 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port,
|
||||
jboolean v4MappedAddress)
|
||||
{
|
||||
jint family = getInetAddress_family(env, iaObj);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, -1);
|
||||
memset((char *)sa, 0, sizeof(SOCKETADDRESS));
|
||||
|
||||
if (ipv6_available() &&
|
||||
@@ -777,6 +778,7 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port,
|
||||
// convert to IPv4-mapped address
|
||||
memset((char *)caddr, 0, 16);
|
||||
address = getInetAddress_addr(env, iaObj);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, -1);
|
||||
if (address == INADDR_ANY) {
|
||||
/* we would always prefer IPv6 wildcard address
|
||||
* caddr[10] = 0xff;
|
||||
@@ -871,6 +873,7 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port,
|
||||
return -1;
|
||||
}
|
||||
address = getInetAddress_addr(env, iaObj);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, -1);
|
||||
sa->sa4.sin_port = htons(port);
|
||||
sa->sa4.sin_addr.s_addr = htonl(address);
|
||||
sa->sa4.sin_family = AF_INET;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -146,7 +146,11 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
|
||||
}
|
||||
setInetAddress_addr(env, iaObj, ntohl(((struct sockaddr_in *)
|
||||
(iterator->ai_addr))->sin_addr.s_addr));
|
||||
if ((*env)->ExceptionCheck(env))
|
||||
goto cleanupAndReturn;
|
||||
setInetAddress_hostName(env, iaObj, host);
|
||||
if ((*env)->ExceptionCheck(env))
|
||||
goto cleanupAndReturn;
|
||||
(*env)->SetObjectArrayElement(env, ret, i++, iaObj);
|
||||
iterator = iterator->ai_next;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -187,7 +187,11 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
|
||||
goto cleanupAndReturn;
|
||||
}
|
||||
setInetAddress_addr(env, iaObj, ntohl(((struct sockaddr_in*)iterator->ai_addr)->sin_addr.s_addr));
|
||||
if ((*env)->ExceptionCheck(env))
|
||||
goto cleanupAndReturn;
|
||||
setInetAddress_hostName(env, iaObj, host);
|
||||
if ((*env)->ExceptionCheck(env))
|
||||
goto cleanupAndReturn;
|
||||
(*env)->SetObjectArrayElement(env, ret, (inetIndex | originalIndex), iaObj);
|
||||
inetIndex++;
|
||||
} else if (iterator->ai_family == AF_INET6) {
|
||||
@@ -208,6 +212,8 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
|
||||
setInet6Address_scopeid(env, iaObj, scope);
|
||||
}
|
||||
setInetAddress_hostName(env, iaObj, host);
|
||||
if ((*env)->ExceptionCheck(env))
|
||||
goto cleanupAndReturn;
|
||||
(*env)->SetObjectArrayElement(env, ret, (inet6Index | originalIndex), iaObj);
|
||||
inet6Index++;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -280,6 +280,7 @@ int enumInterfaces(JNIEnv *env, netif **netifPP)
|
||||
if (curr->name == NULL || curr->displayName == NULL) {
|
||||
if (curr->name) free(curr->name);
|
||||
if (curr->displayName) free(curr->displayName);
|
||||
free(curr);
|
||||
curr = NULL;
|
||||
}
|
||||
}
|
||||
@@ -586,6 +587,10 @@ jobject createNetworkInterface
|
||||
/* default ctor will set family to AF_INET */
|
||||
|
||||
setInetAddress_addr(env, iaObj, ntohl(addrs->addr.sa4.sin_addr.s_addr));
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
free_netaddr(netaddrP);
|
||||
return NULL;
|
||||
}
|
||||
if (addrs->mask != -1) {
|
||||
ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID);
|
||||
if (ibObj == NULL) {
|
||||
@@ -599,6 +604,10 @@ jobject createNetworkInterface
|
||||
return NULL;
|
||||
}
|
||||
setInetAddress_addr(env, ia2Obj, ntohl(addrs->brdcast.sa4.sin_addr.s_addr));
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
free_netaddr(netaddrP);
|
||||
return NULL;
|
||||
}
|
||||
(*env)->SetObjectField(env, ibObj, ni_ibbroadcastID, ia2Obj);
|
||||
(*env)->SetShortField(env, ibObj, ni_ibmaskID, addrs->mask);
|
||||
(*env)->SetObjectArrayElement(env, bindsArr, bind_index++, ibObj);
|
||||
@@ -609,6 +618,7 @@ jobject createNetworkInterface
|
||||
if (iaObj) {
|
||||
jboolean ret = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(addrs->addr.sa6.sin6_addr.s6_addr));
|
||||
if (ret == JNI_FALSE) {
|
||||
free_netaddr(netaddrP);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -754,8 +764,9 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0
|
||||
(JNIEnv *env, jclass cls, jobject iaObj)
|
||||
{
|
||||
netif *ifList, *curr;
|
||||
jint addr = getInetAddress_addr(env, iaObj);
|
||||
jobject netifObj = NULL;
|
||||
jint addr = getInetAddress_addr(env, iaObj);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
|
||||
|
||||
// Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
|
||||
if (ipv6_available()) {
|
||||
|
||||
@@ -521,8 +521,9 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
|
||||
jobjectArray addrArr, bindsArr, childArr;
|
||||
netaddr *addrs;
|
||||
jint addr_index;
|
||||
int netaddrCount=ifs->naddrs;
|
||||
netaddr *netaddrP=ifs->addrs;
|
||||
int netaddrCount = ifs->naddrs;
|
||||
netaddr *netaddrP = ifs->addrs;
|
||||
netaddr *netaddrPToFree = NULL;
|
||||
jint bind_index;
|
||||
|
||||
/*
|
||||
@@ -553,21 +554,23 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
|
||||
* Note that 0 is a valid number of addresses.
|
||||
*/
|
||||
if (netaddrCount < 0) {
|
||||
netaddrCount = enumAddresses_win(env, ifs, &netaddrP);
|
||||
netaddrCount = enumAddresses_win(env, ifs, &netaddrPToFree);
|
||||
if (netaddrCount == -1) {
|
||||
return NULL;
|
||||
}
|
||||
netaddrP = netaddrPToFree;
|
||||
}
|
||||
|
||||
addrArr = (*env)->NewObjectArray(env, netaddrCount, ia_class, NULL);
|
||||
if (addrArr == NULL) {
|
||||
free_netaddr(netaddrPToFree);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bindsArr = (*env)->NewObjectArray(env, netaddrCount, ni_ibcls, NULL);
|
||||
if (bindsArr == NULL) {
|
||||
free_netaddr(netaddrP);
|
||||
return NULL;
|
||||
free_netaddr(netaddrPToFree);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
addrs = netaddrP;
|
||||
@@ -579,24 +582,32 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
|
||||
if (addrs->addr.sa.sa_family == AF_INET) {
|
||||
iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
|
||||
if (iaObj == NULL) {
|
||||
free_netaddr(netaddrPToFree);
|
||||
return NULL;
|
||||
}
|
||||
/* default ctor will set family to AF_INET */
|
||||
|
||||
setInetAddress_addr(env, iaObj, ntohl(addrs->addr.sa4.sin_addr.s_addr));
|
||||
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
free_netaddr(netaddrPToFree);
|
||||
return NULL;
|
||||
}
|
||||
ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID);
|
||||
if (ibObj == NULL) {
|
||||
free_netaddr(netaddrP);
|
||||
return NULL;
|
||||
free_netaddr(netaddrPToFree);
|
||||
return NULL;
|
||||
}
|
||||
(*env)->SetObjectField(env, ibObj, ni_ibaddressID, iaObj);
|
||||
ia2Obj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
|
||||
if (ia2Obj == NULL) {
|
||||
free_netaddr(netaddrP);
|
||||
return NULL;
|
||||
free_netaddr(netaddrPToFree);
|
||||
return NULL;
|
||||
}
|
||||
setInetAddress_addr(env, ia2Obj, ntohl(addrs->brdcast.sa4.sin_addr.s_addr));
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
free_netaddr(netaddrPToFree);
|
||||
return NULL;
|
||||
}
|
||||
(*env)->SetObjectField(env, ibObj, ni_ibbroadcastID, ia2Obj);
|
||||
(*env)->SetShortField(env, ibObj, ni_ibmaskID, addrs->mask);
|
||||
(*env)->SetObjectArrayElement(env, bindsArr, bind_index++, ibObj);
|
||||
@@ -605,10 +616,12 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
|
||||
jboolean ret;
|
||||
iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
|
||||
if (iaObj == NULL) {
|
||||
free_netaddr(netaddrPToFree);
|
||||
return NULL;
|
||||
}
|
||||
ret = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(addrs->addr.sa6.sin6_addr.s6_addr));
|
||||
if (ret == JNI_FALSE) {
|
||||
free_netaddr(netaddrPToFree);
|
||||
return NULL;
|
||||
}
|
||||
scope = addrs->addr.sa6.sin6_scope_id;
|
||||
@@ -618,8 +631,8 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
|
||||
}
|
||||
ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID);
|
||||
if (ibObj == NULL) {
|
||||
free_netaddr(netaddrP);
|
||||
return NULL;
|
||||
free_netaddr(netaddrPToFree);
|
||||
return NULL;
|
||||
}
|
||||
(*env)->SetObjectField(env, ibObj, ni_ibaddressID, iaObj);
|
||||
(*env)->SetShortField(env, ibObj, ni_ibmaskID, addrs->mask);
|
||||
@@ -632,6 +645,8 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
|
||||
(*env)->SetObjectField(env, netifObj, ni_addrsID, addrArr);
|
||||
(*env)->SetObjectField(env, netifObj, ni_bindsID, bindsArr);
|
||||
|
||||
free_netaddr(netaddrPToFree);
|
||||
|
||||
/*
|
||||
* Windows doesn't have virtual interfaces, so child array
|
||||
* is always empty.
|
||||
@@ -671,7 +686,7 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0_XP
|
||||
}
|
||||
|
||||
/* if found create a NetworkInterface */
|
||||
if (curr != NULL) {;
|
||||
if (curr != NULL) {
|
||||
netifObj = createNetworkInterfaceXP(env, curr);
|
||||
}
|
||||
|
||||
@@ -798,6 +813,7 @@ JNIEXPORT jobjectArray JNICALL Java_java_net_NetworkInterface_getAll_XP
|
||||
/* allocate a NetworkInterface array */
|
||||
netIFArr = (*env)->NewObjectArray(env, count, cls, NULL);
|
||||
if (netIFArr == NULL) {
|
||||
free_netif(ifList);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -812,6 +828,7 @@ JNIEXPORT jobjectArray JNICALL Java_java_net_NetworkInterface_getAll_XP
|
||||
|
||||
netifObj = createNetworkInterfaceXP(env, curr);
|
||||
if (netifObj == NULL) {
|
||||
free_netif(ifList);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -219,16 +219,16 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this,
|
||||
jobject fd1Obj = (*env)->GetObjectField(env, this, pdsi_fd1ID);
|
||||
int ipv6_supported = ipv6_available();
|
||||
int fd, fd1 = -1, lcladdrlen = 0;
|
||||
jint family;
|
||||
SOCKETADDRESS lcladdr;
|
||||
|
||||
if (getInetAddress_family(env, addressObj) == java_net_InetAddress_IPv6 &&
|
||||
!ipv6_supported)
|
||||
{
|
||||
family = getInetAddress_family(env, addressObj);
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
if (family == java_net_InetAddress_IPv6 && !ipv6_supported) {
|
||||
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
|
||||
"Protocol family not supported");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IS_NULL(fdObj) || (ipv6_supported && IS_NULL(fd1Obj))) {
|
||||
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "socket closed");
|
||||
return;
|
||||
@@ -344,6 +344,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_connect0
|
||||
}
|
||||
|
||||
family = getInetAddress_family(env, address);
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
if (family == java_net_InetAddress_IPv6 && !ipv6_available()) {
|
||||
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
|
||||
"Protocol family not supported");
|
||||
@@ -455,6 +456,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_send
|
||||
}
|
||||
|
||||
family = getInetAddress_family(env, iaObj);
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
if (family == java_net_InetAddress_IPv4) {
|
||||
fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
|
||||
} else {
|
||||
@@ -584,6 +586,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_peek(JNIEnv *env, jobject this,
|
||||
return -1;
|
||||
} else {
|
||||
address = getInetAddress_addr(env, addressObj);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, -1);
|
||||
/* We only handle IPv4 for now. Will support IPv6 once its in the os */
|
||||
family = AF_INET;
|
||||
}
|
||||
@@ -657,7 +660,9 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_peek(JNIEnv *env, jobject this,
|
||||
return 0;
|
||||
}
|
||||
setInetAddress_addr(env, addressObj, ntohl(remote_addr.sa4.sin_addr.s_addr));
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, -1);
|
||||
setInetAddress_family(env, addressObj, java_net_InetAddress_IPv4);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, -1);
|
||||
|
||||
/* return port */
|
||||
return ntohs(remote_addr.sa4.sin_port);
|
||||
@@ -1349,6 +1354,7 @@ static int getInetAddrFromIf (JNIEnv *env, int family, jobject nif, jobject *iad
|
||||
int fam;
|
||||
addr = (*env)->GetObjectArrayElement(env, addrArray, i);
|
||||
fam = getInetAddress_family(env, addr);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, -1);
|
||||
if (fam == family) {
|
||||
*iaddr = addr;
|
||||
return 0;
|
||||
@@ -1367,6 +1373,7 @@ static int getInet4AddrFromIf (JNIEnv *env, jobject nif, struct in_addr *iaddr)
|
||||
}
|
||||
|
||||
iaddr->s_addr = htonl(getInetAddress_addr(env, addr));
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, -1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1471,6 +1478,7 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1,
|
||||
struct in_addr in;
|
||||
|
||||
in.s_addr = htonl(getInetAddress_addr(env, value));
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
|
||||
(const char*)&in, sizeof(in)) < 0) {
|
||||
JNU_ThrowByNameWithMessageAndLastError
|
||||
@@ -1712,7 +1720,7 @@ static jobject getIPv4NetworkInterface (JNIEnv *env, jobject this, int fd, jint
|
||||
CHECK_NULL_RETURN(addr, NULL);
|
||||
|
||||
setInetAddress_addr(env, addr, ntohl(in.s_addr));
|
||||
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
|
||||
/*
|
||||
* For IP_MULTICAST_IF return InetAddress
|
||||
*/
|
||||
|
||||
@@ -794,6 +794,7 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port,
|
||||
jboolean v4MappedAddress)
|
||||
{
|
||||
jint family = getInetAddress_family(env, iaObj);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, -1);
|
||||
memset((char *)sa, 0, sizeof(SOCKETADDRESS));
|
||||
|
||||
if (ipv6_available() &&
|
||||
@@ -808,6 +809,7 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port,
|
||||
// convert to IPv4-mapped address
|
||||
memset((char *)caddr, 0, 16);
|
||||
address = getInetAddress_addr(env, iaObj);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, -1);
|
||||
if (address == INADDR_ANY) {
|
||||
/* we would always prefer IPv6 wildcard address
|
||||
* caddr[10] = 0xff;
|
||||
@@ -846,6 +848,7 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port,
|
||||
return -1;
|
||||
}
|
||||
address = getInetAddress_addr(env, iaObj);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, -1);
|
||||
sa->sa4.sin_port = htons((short)port);
|
||||
sa->sa4.sin_addr.s_addr = (u_long)htonl(address);
|
||||
sa->sa4.sin_family = AF_INET;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -364,11 +364,11 @@ public class FileManager {
|
||||
* @since Java for Mac OS X 10.5 Update 6 - 1.6, 1.5
|
||||
*/
|
||||
public static boolean moveToTrash(final File file) throws FileNotFoundException {
|
||||
if (file == null || !file.exists()) throw new FileNotFoundException();
|
||||
if (file == null) throw new FileNotFoundException();
|
||||
final String fileName = file.getAbsolutePath();
|
||||
|
||||
final SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) security.checkWrite(fileName);
|
||||
if (security != null) security.checkDelete(fileName);
|
||||
|
||||
return _moveToTrash(fileName);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -42,6 +42,9 @@ import java.io.FilePermission;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.swing.JMenuBar;
|
||||
@@ -363,15 +366,11 @@ public class Desktop {
|
||||
* @throws NullPointerException if file is null
|
||||
* @throws IllegalArgumentException if file doesn't exist
|
||||
*/
|
||||
private static void checkFileValidation(File file){
|
||||
if (file == null) throw new NullPointerException("File must not be null");
|
||||
|
||||
private static void checkFileValidation(File file) {
|
||||
if (!file.exists()) {
|
||||
throw new IllegalArgumentException("The file: "
|
||||
+ file.getPath() + " doesn't exist.");
|
||||
}
|
||||
|
||||
file.canRead();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -425,6 +424,7 @@ public class Desktop {
|
||||
* @see java.awt.AWTPermission
|
||||
*/
|
||||
public void open(File file) throws IOException {
|
||||
file = new File(file.getPath());
|
||||
checkAWTPermission();
|
||||
checkExec();
|
||||
checkActionSupport(Action.OPEN);
|
||||
@@ -456,6 +456,7 @@ public class Desktop {
|
||||
* @see java.awt.AWTPermission
|
||||
*/
|
||||
public void edit(File file) throws IOException {
|
||||
file = new File(file.getPath());
|
||||
checkAWTPermission();
|
||||
checkExec();
|
||||
checkActionSupport(Action.EDIT);
|
||||
@@ -486,6 +487,7 @@ public class Desktop {
|
||||
* allowed to create a subprocess
|
||||
*/
|
||||
public void print(File file) throws IOException {
|
||||
file = new File(file.getPath());
|
||||
checkExec();
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
@@ -614,14 +616,6 @@ public class Desktop {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDelete() throws SecurityException {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(new FilePermission("<<ALL FILES>>",
|
||||
SecurityConstants.FILE_DELETE_ACTION));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkQuitPermission() {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
@@ -950,6 +944,8 @@ public class Desktop {
|
||||
* @since 9
|
||||
*/
|
||||
public void openHelpViewer() {
|
||||
checkAWTPermission();
|
||||
checkExec();
|
||||
checkEventsProcessingPermission();
|
||||
checkActionSupport(Action.APP_HELP_VIEWER);
|
||||
peer.openHelpViewer();
|
||||
@@ -995,9 +991,15 @@ public class Desktop {
|
||||
* @since 9
|
||||
*/
|
||||
public void browseFileDirectory(File file) {
|
||||
checkRead();
|
||||
file = new File(file.getPath());
|
||||
checkAWTPermission();
|
||||
checkExec();
|
||||
checkActionSupport(Action.BROWSE_FILE_DIR);
|
||||
checkFileValidation(file);
|
||||
File parentFile = file.getParentFile();
|
||||
if (parentFile == null || !parentFile.exists()) {
|
||||
throw new IllegalArgumentException("Parent folder doesn't exist");
|
||||
}
|
||||
peer.browseFileDirectory(file);
|
||||
}
|
||||
|
||||
@@ -1017,10 +1019,18 @@ public class Desktop {
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public boolean moveToTrash(final File file) {
|
||||
checkDelete();
|
||||
public boolean moveToTrash(File file) {
|
||||
file = new File(file.getPath());
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkDelete(file.getPath());
|
||||
}
|
||||
checkActionSupport(Action.MOVE_TO_TRASH);
|
||||
checkFileValidation(file);
|
||||
final File finalFile = file;
|
||||
AccessController.doPrivileged((PrivilegedAction<?>) () -> {
|
||||
checkFileValidation(finalFile);
|
||||
return null;
|
||||
});
|
||||
return peer.moveToTrash(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -733,7 +733,7 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
}
|
||||
|
||||
try {
|
||||
return invoke(new Callable<File[]>() {
|
||||
File[] files = invoke(new Callable<File[]>() {
|
||||
public File[] call() throws InterruptedException {
|
||||
if (!isDirectory()) {
|
||||
return null;
|
||||
@@ -788,6 +788,8 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
: list.toArray(new ShellFolder[list.size()]);
|
||||
}
|
||||
}, InterruptedException.class);
|
||||
|
||||
return Win32ShellFolderManager2.checkFiles(files);
|
||||
} catch (InterruptedException e) {
|
||||
return new File[0];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -387,21 +387,30 @@ final class Win32ShellFolderManager2 extends ShellFolderManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
private File checkFile(File file) {
|
||||
private static File checkFile(File file) {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
return (sm == null || file == null) ? file : checkFile(file, sm);
|
||||
}
|
||||
|
||||
private File checkFile(File file, SecurityManager sm) {
|
||||
private static File checkFile(File file, SecurityManager sm) {
|
||||
try {
|
||||
sm.checkRead(file.getPath());
|
||||
|
||||
if (file instanceof Win32ShellFolder2) {
|
||||
Win32ShellFolder2 f = (Win32ShellFolder2)file;
|
||||
if (f.isLink()) {
|
||||
Win32ShellFolder2 link = (Win32ShellFolder2)f.getLinkLocation();
|
||||
if (link != null)
|
||||
sm.checkRead(link.getPath());
|
||||
}
|
||||
}
|
||||
return file;
|
||||
} catch (SecurityException se) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private File[] checkFiles(File[] files) {
|
||||
static File[] checkFiles(File[] files) {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm == null || files == null || files.length == 0) {
|
||||
return files;
|
||||
@@ -409,7 +418,7 @@ final class Win32ShellFolderManager2 extends ShellFolderManager {
|
||||
return checkFiles(Arrays.stream(files), sm);
|
||||
}
|
||||
|
||||
private File[] checkFiles(List<File> files) {
|
||||
private static File[] checkFiles(List<File> files) {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm == null || files.isEmpty()) {
|
||||
return files.toArray(new File[files.size()]);
|
||||
@@ -417,7 +426,7 @@ final class Win32ShellFolderManager2 extends ShellFolderManager {
|
||||
return checkFiles(files.stream(), sm);
|
||||
}
|
||||
|
||||
private File[] checkFiles(Stream<File> filesStream, SecurityManager sm) {
|
||||
private static File[] checkFiles(Stream<File> filesStream, SecurityManager sm) {
|
||||
return filesStream.filter((file) -> checkFile(file, sm) != null)
|
||||
.toArray(File[]::new);
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ INT32 MIDI_IN_GetNumDevices() {
|
||||
}
|
||||
|
||||
INT32 getMidiInCaps(INT32 deviceID, MIDIINCAPSW* caps, INT32* err) {
|
||||
(*err) = midiInGetDevCapsW(deviceID, caps, sizeof(MIDIINCAPS));
|
||||
(*err) = midiInGetDevCapsW(deviceID, caps, sizeof(MIDIINCAPSW));
|
||||
return ((*err) == MMSYSERR_NOERROR);
|
||||
}
|
||||
|
||||
@@ -260,6 +260,7 @@ INT32 MIDI_IN_GetDeviceName(INT32 deviceID, char *name, UINT32 nameLength) {
|
||||
MIDIINCAPSW midiInCaps;
|
||||
INT32 err;
|
||||
|
||||
memset(&midiInCaps, 0, sizeof(midiInCaps));
|
||||
if (getMidiInCaps(deviceID, &midiInCaps, &err)) {
|
||||
UnicodeToUTF8AndCopy(name, midiInCaps.szPname, nameLength);
|
||||
return MIDI_SUCCESS;
|
||||
@@ -284,6 +285,7 @@ INT32 MIDI_IN_GetDeviceVersion(INT32 deviceID, char *name, UINT32 nameLength) {
|
||||
MIDIINCAPSW midiInCaps;
|
||||
INT32 err = MIDI_NOT_SUPPORTED;
|
||||
|
||||
memset(&midiInCaps, 0, sizeof(midiInCaps));
|
||||
if (getMidiInCaps(deviceID, &midiInCaps, &err) && (nameLength>7)) {
|
||||
sprintf(name, "%d.%d", (midiInCaps.vDriverVersion & 0xFF00) >> 8, midiInCaps.vDriverVersion & 0xFF);
|
||||
return MIDI_SUCCESS;
|
||||
|
||||
@@ -70,12 +70,13 @@ INT32 MIDI_OUT_GetNumDevices() {
|
||||
|
||||
|
||||
INT32 getMidiOutCaps(INT32 deviceID, MIDIOUTCAPSW* caps, INT32* err) {
|
||||
UINT_PTR id;
|
||||
if (deviceID == 0) {
|
||||
deviceID = MIDI_MAPPER;
|
||||
id = MIDI_MAPPER;
|
||||
} else {
|
||||
deviceID--;
|
||||
id = (UINT_PTR)(deviceID-1);
|
||||
}
|
||||
(*err) = (INT32) midiOutGetDevCapsW(deviceID, caps, sizeof(MIDIOUTCAPS));
|
||||
(*err) = (INT32) midiOutGetDevCapsW(id, caps, sizeof(MIDIOUTCAPSW));
|
||||
return ((*err) == MMSYSERR_NOERROR);
|
||||
}
|
||||
|
||||
@@ -84,6 +85,7 @@ INT32 MIDI_OUT_GetDeviceName(INT32 deviceID, char *name, UINT32 nameLength) {
|
||||
MIDIOUTCAPSW midiOutCaps;
|
||||
INT32 err;
|
||||
|
||||
memset(&midiOutCaps, 0, sizeof(midiOutCaps));
|
||||
if (getMidiOutCaps(deviceID, &midiOutCaps, &err)) {
|
||||
UnicodeToUTF8AndCopy(name, midiOutCaps.szPname, nameLength);
|
||||
return MIDI_SUCCESS;
|
||||
@@ -103,6 +105,7 @@ INT32 MIDI_OUT_GetDeviceDescription(INT32 deviceID, char *name, UINT32 nameLengt
|
||||
char *desc;
|
||||
INT32 err;
|
||||
|
||||
memset(&midiOutCaps, 0, sizeof(midiOutCaps));
|
||||
if (getMidiOutCaps(deviceID, &midiOutCaps, &err)) {
|
||||
int tech = (int)midiOutCaps.wTechnology;
|
||||
switch(tech) {
|
||||
@@ -139,6 +142,7 @@ INT32 MIDI_OUT_GetDeviceVersion(INT32 deviceID, char *name, UINT32 nameLength) {
|
||||
MIDIOUTCAPSW midiOutCaps;
|
||||
INT32 err;
|
||||
|
||||
memset(&midiOutCaps, 0, sizeof(midiOutCaps));
|
||||
if (getMidiOutCaps(deviceID, &midiOutCaps, &err) && nameLength>7) {
|
||||
sprintf(name, "%d.%d", (midiOutCaps.vDriverVersion & 0xFF00) >> 8, midiOutCaps.vDriverVersion & 0xFF);
|
||||
return MIDI_SUCCESS;
|
||||
|
||||
@@ -357,7 +357,7 @@ int lineHasControls(HMIXER handle, MIXERLINE* line, MIXERLINECONTROLS* controls)
|
||||
|
||||
INT32 PORT_GetPortMixerDescription(INT32 mixerIndex, PortMixerDescription* description) {
|
||||
MIXERCAPSW mixerCaps;
|
||||
if (mixerGetDevCapsW(mixerIndex, &mixerCaps, sizeof(MIXERCAPS)) == MMSYSERR_NOERROR) {
|
||||
if (mixerGetDevCapsW(mixerIndex, &mixerCaps, sizeof(MIXERCAPSW)) == MMSYSERR_NOERROR) {
|
||||
UnicodeToUTF8AndCopy(description->name, mixerCaps.szPname, PORT_STRING_LENGTH);
|
||||
sprintf(description->version, "%d.%d", (mixerCaps.vDriverVersion & 0xFF00) >> 8, mixerCaps.vDriverVersion & 0xFF);
|
||||
strncpy(description->description, "Port Mixer", PORT_STRING_LENGTH-1);
|
||||
@@ -368,9 +368,9 @@ INT32 PORT_GetPortMixerDescription(INT32 mixerIndex, PortMixerDescription* descr
|
||||
|
||||
int getDestinationCount(HMIXER handle) {
|
||||
int ret = 0;
|
||||
MIXERCAPS mixerCaps;
|
||||
MIXERCAPSW mixerCaps;
|
||||
|
||||
if (mixerGetDevCaps((UINT_PTR) handle, &mixerCaps, sizeof(MIXERCAPS)) == MMSYSERR_NOERROR) {
|
||||
if (mixerGetDevCapsW((UINT_PTR) handle, &mixerCaps, sizeof(MIXERCAPSW)) == MMSYSERR_NOERROR) {
|
||||
ret = mixerCaps.cDestinations;
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -44,8 +44,11 @@ import javax.naming.ldap.Control;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Arrays;
|
||||
import javax.net.SocketFactory;
|
||||
import javax.net.ssl.SSLParameters;
|
||||
|
||||
/**
|
||||
* A thread that creates a connection to an LDAP server.
|
||||
@@ -158,7 +161,18 @@ public final class Connection implements Runnable {
|
||||
|
||||
int readTimeout;
|
||||
int connectTimeout;
|
||||
private static final boolean IS_HOSTNAME_VERIFICATION_DISABLED
|
||||
= hostnameVerificationDisabledValue();
|
||||
|
||||
private static boolean hostnameVerificationDisabledValue() {
|
||||
PrivilegedAction<String> act = () -> System.getProperty(
|
||||
"com.sun.jndi.ldap.object.disableEndpointIdentification");
|
||||
String prop = AccessController.doPrivileged(act);
|
||||
if (prop == null) {
|
||||
return false;
|
||||
}
|
||||
return prop.isEmpty() ? true : Boolean.parseBoolean(prop);
|
||||
}
|
||||
// true means v3; false means v2
|
||||
// Called in LdapClient.authenticate() (which is synchronized)
|
||||
// when connection is "quiet" and not shared; no need to synchronize
|
||||
@@ -321,15 +335,20 @@ public final class Connection implements Runnable {
|
||||
// the SSL handshake following socket connection as part of the timeout.
|
||||
// So explicitly set a socket read timeout, trigger the SSL handshake,
|
||||
// then reset the timeout.
|
||||
if (connectTimeout > 0 && socket instanceof SSLSocket) {
|
||||
if (socket instanceof SSLSocket) {
|
||||
SSLSocket sslSocket = (SSLSocket) socket;
|
||||
int socketTimeout = sslSocket.getSoTimeout();
|
||||
|
||||
sslSocket.setSoTimeout(connectTimeout); // reuse full timeout value
|
||||
if (!IS_HOSTNAME_VERIFICATION_DISABLED) {
|
||||
SSLParameters param = sslSocket.getSSLParameters();
|
||||
param.setEndpointIdentificationAlgorithm("LDAPS");
|
||||
sslSocket.setSSLParameters(param);
|
||||
}
|
||||
if (connectTimeout > 0) {
|
||||
sslSocket.setSoTimeout(connectTimeout); // reuse full timeout value
|
||||
}
|
||||
sslSocket.startHandshake();
|
||||
sslSocket.setSoTimeout(socketTimeout);
|
||||
}
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -53,6 +53,20 @@ import java.util.*;
|
||||
public final class VersionHelper {
|
||||
private static final VersionHelper helper = new VersionHelper();
|
||||
|
||||
/**
|
||||
* Determines whether classes may be loaded from an arbitrary URL code base.
|
||||
*/
|
||||
private static final boolean TRUST_URL_CODE_BASE;
|
||||
|
||||
static {
|
||||
// System property to control whether classes may be loaded from an
|
||||
// arbitrary URL code base
|
||||
PrivilegedAction<String> act
|
||||
= () -> System.getProperty("com.sun.jndi.ldap.object.trustURLCodebase", "false");
|
||||
String trust = AccessController.doPrivileged(act);
|
||||
TRUST_URL_CODE_BASE = "true".equalsIgnoreCase(trust);
|
||||
}
|
||||
|
||||
final static String[] PROPS = new String[]{
|
||||
javax.naming.Context.INITIAL_CONTEXT_FACTORY,
|
||||
javax.naming.Context.OBJECT_FACTORIES,
|
||||
@@ -88,12 +102,14 @@ public final class VersionHelper {
|
||||
*/
|
||||
public Class<?> loadClass(String className, String codebase)
|
||||
throws ClassNotFoundException, MalformedURLException {
|
||||
|
||||
ClassLoader parent = getContextClassLoader();
|
||||
ClassLoader cl =
|
||||
URLClassLoader.newInstance(getUrlArray(codebase), parent);
|
||||
|
||||
return loadClass(className, cl);
|
||||
if (TRUST_URL_CODE_BASE) {
|
||||
ClassLoader parent = getContextClassLoader();
|
||||
ClassLoader cl
|
||||
= URLClassLoader.newInstance(getUrlArray(codebase), parent);
|
||||
return loadClass(className, cl);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -190,6 +190,7 @@ import jdk.xml.internal.SecuritySupport;
|
||||
* @author Sunitha Reddy
|
||||
* @see javax.xml.datatype.Duration
|
||||
* @since 1.5
|
||||
* @LastModified: June 2018
|
||||
*/
|
||||
|
||||
public class XMLGregorianCalendarImpl
|
||||
@@ -2755,7 +2756,7 @@ public class XMLGregorianCalendarImpl
|
||||
if ((fractional.compareTo(DECIMAL_ZERO) < 0) ||
|
||||
(fractional.compareTo(DECIMAL_ONE) > 0)) {
|
||||
throw new IllegalArgumentException(DatatypeMessageFormatter.formatMessage(null,
|
||||
"InvalidFractional", new Object[]{fractional}));
|
||||
"InvalidFractional", new Object[]{fractional.toString()}));
|
||||
}
|
||||
}
|
||||
this.fractionalSecond = fractional;
|
||||
|
||||
@@ -311,6 +311,9 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_PRNG_generateSeed
|
||||
}
|
||||
|
||||
result = env->NewByteArray(length);
|
||||
if (result == NULL) {
|
||||
__leave;
|
||||
}
|
||||
env->SetByteArrayRegion(result, 0, length, (jbyte*) pbData);
|
||||
|
||||
} else { // length == 0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -1601,13 +1601,14 @@ public final class Global extends Scope {
|
||||
}
|
||||
}
|
||||
|
||||
switch (nameStr) {
|
||||
case "context":
|
||||
if ("context".equals(nameStr)) {
|
||||
return sctxt;
|
||||
case "engine":
|
||||
return global.engine;
|
||||
default:
|
||||
break;
|
||||
} else if ("engine".equals(nameStr)) {
|
||||
// expose "engine" variable only when there is no security manager
|
||||
// or when no class filter is set.
|
||||
if (System.getSecurityManager() == null || global.getClassFilter() == null) {
|
||||
return global.engine;
|
||||
}
|
||||
}
|
||||
|
||||
if (self == UNDEFINED) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8132734 8144062 8165723
|
||||
* @bug 8132734 8144062 8165723 8199172
|
||||
* @summary Test the extended API and the aliasing additions in JarFile that
|
||||
* support multi-release jar files
|
||||
* @library /lib/testlibrary/java/util/jar /test/lib
|
||||
@@ -100,16 +100,30 @@ public class MultiReleaseJarAPI {
|
||||
testCustomMultiReleaseValue("true", true);
|
||||
testCustomMultiReleaseValue("true\r\nOther: value", true);
|
||||
testCustomMultiReleaseValue("true\nOther: value", true);
|
||||
testCustomMultiReleaseValue("true\rOther: value", true);
|
||||
// JDK-8200530: '\r' support in Manifest/Attributes will be addressed separately
|
||||
// testCustomMultiReleaseValue("true\rOther: value", true);
|
||||
|
||||
testCustomMultiReleaseValue("false", false);
|
||||
testCustomMultiReleaseValue(" true", false);
|
||||
testCustomMultiReleaseValue("true ", false);
|
||||
testCustomMultiReleaseValue("true\n ", false);
|
||||
testCustomMultiReleaseValue("true\r ", false);
|
||||
testCustomMultiReleaseValue("true\n true", false);
|
||||
|
||||
// JDK-8200530: '\r' support in Manifest/Attributes will be addressed separately
|
||||
testCustomMultiReleaseValue("true\r true", false);
|
||||
testCustomMultiReleaseValue("true\r\n true", false);
|
||||
|
||||
// "Multi-Release: true/false" not in main attributes
|
||||
testCustomMultiReleaseValue("\r\n\r\nName: test\r\nMulti-Release: true\r\n",
|
||||
false);
|
||||
testCustomMultiReleaseValue("\n\nName: entryname\nMulti-Release: true\n",
|
||||
false);
|
||||
testCustomMultiReleaseValue("EndOfMainAttr: whatever\r\n" +
|
||||
"\r\nName: entryname\r\nMulti-Release: true\r\n",
|
||||
false);
|
||||
testCustomMultiReleaseValue("EndOfMainAttr: whatever\r\n" +
|
||||
"\nName: entryname\nMulti-Release: true\n",
|
||||
false);
|
||||
|
||||
// generate "random" Strings to use as extra attributes, and
|
||||
// verify that Multi-Release: true is always properly matched
|
||||
for (int i = 0; i < 100; i++) {
|
||||
|
||||
@@ -142,6 +142,12 @@ public class CreateMultiReleaseTestJars {
|
||||
}
|
||||
|
||||
public void buildSignedMultiReleaseJar() throws Exception {
|
||||
buildSignedMultiReleaseJar("multi-release.jar", "signed-multi-release.jar");
|
||||
}
|
||||
|
||||
public void buildSignedMultiReleaseJar(String multiReleaseJar,
|
||||
String signedMultiReleaseJar) throws Exception
|
||||
{
|
||||
String testsrc = System.getProperty("test.src",".");
|
||||
String testdir = findTestDir(testsrc);
|
||||
String keystore = testdir + "/sun/security/tools/jarsigner/JarSigning.keystore";
|
||||
@@ -155,8 +161,8 @@ public class CreateMultiReleaseTestJars {
|
||||
CertPath cp = CertificateFactory.getInstance("X.509")
|
||||
.generateCertPath(Arrays.asList(ks.getCertificateChain("b")));
|
||||
JarSigner js = new JarSigner.Builder(pkb, cp).build();
|
||||
try (ZipFile in = new ZipFile("multi-release.jar");
|
||||
FileOutputStream os = new FileOutputStream("signed-multi-release.jar"))
|
||||
try (ZipFile in = new ZipFile(multiReleaseJar);
|
||||
FileOutputStream os = new FileOutputStream(signedMultiReleaseJar))
|
||||
{
|
||||
js.sign(in, os);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
package jdk.test.lib.util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -126,6 +127,11 @@ public final class JarUtils {
|
||||
changes = new HashMap<>(changes);
|
||||
|
||||
System.out.printf("Creating %s from %s...\n", dest, src);
|
||||
|
||||
if (dest.equals(src)) {
|
||||
throw new IOException("src and dest cannot be the same");
|
||||
}
|
||||
|
||||
try (JarOutputStream jos = new JarOutputStream(
|
||||
new FileOutputStream(dest))) {
|
||||
|
||||
@@ -153,6 +159,22 @@ public final class JarUtils {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Manifest inside a jar.
|
||||
*
|
||||
* @param src the original jar file name
|
||||
* @param dest the new jar file name
|
||||
* @param man the Manifest
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void updateManifest(String src, String dest, Manifest man)
|
||||
throws IOException {
|
||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||
man.write(bout);
|
||||
updateJar(src, dest, Map.of(JarFile.MANIFEST_NAME, bout.toByteArray()));
|
||||
}
|
||||
|
||||
private static void updateEntry(JarOutputStream jos, String name, Object content)
|
||||
throws IOException {
|
||||
if (content instanceof Boolean) {
|
||||
|
||||
Reference in New Issue
Block a user