Skip to content

Commit 0d35235

Browse files
Roger Riggsslowhog
Roger Riggs
authored andcommittedOct 20, 2020
8249927: Specify limits of jdk.serialProxyInterfaceLimit
corrections to limits defined by 8236862 implemented by 8248183 Reviewed-by: smarks, rhalade, skoivu
1 parent d6cef99 commit 0d35235

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed
 

‎src/java.base/share/classes/java/io/ObjectInputStream.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,12 @@ private static class Caches {
308308

309309
/**
310310
* Property to override the implementation limit on the number
311-
* of interfaces allowed for Proxies.
311+
* of interfaces allowed for Proxies. The property value is clamped to 0..65535.
312312
* The maximum number of interfaces allowed for a proxy is limited to 65535 by
313313
* {@link java.lang.reflect.Proxy#newProxyInstance(ClassLoader, Class[], InvocationHandler)}.
314314
*/
315-
static final int PROXY_INTERFACE_LIMIT = Math.min(65535, GetIntegerAction
316-
.privilegedGetProperty("jdk.serialProxyInterfaceLimit", 65535));
315+
static final int PROXY_INTERFACE_LIMIT = Math.max(0, Math.min(65535, GetIntegerAction
316+
.privilegedGetProperty("jdk.serialProxyInterfaceLimit", 65535)));
317317
}
318318

319319
/*
@@ -1981,6 +1981,11 @@ private ObjectStreamClass readProxyDesc(boolean unshared)
19811981
totalObjectRefs++;
19821982
depth++;
19831983
desc.initProxy(cl, resolveEx, readClassDesc(false));
1984+
} catch (OutOfMemoryError memerr) {
1985+
IOException ex = new InvalidObjectException("Proxy interface limit exceeded: " +
1986+
Arrays.toString(ifaces));
1987+
ex.initCause(memerr);
1988+
throw ex;
19841989
} finally {
19851990
depth--;
19861991
}

0 commit comments

Comments
 (0)
Please sign in to comment.