8203368: ObjectInputStream filterCheck method throws NullPointerException

Reviewed-by: bpb, smarks
This commit is contained in:
Roger Riggs 2018-05-25 13:29:25 -04:00
parent 5634c779d5
commit 474a1253bb
2 changed files with 127 additions and 2 deletions

View file

@ -1263,9 +1263,11 @@ public class ObjectInputStream
if (serialFilter != null) {
RuntimeException ex = null;
ObjectInputFilter.Status status;
// Info about the stream is not available if overridden by subclass, return 0
long bytesRead = (bin == null) ? 0 : bin.getBytesRead();
try {
status = serialFilter.checkInput(new FilterValues(clazz, arrayLength,
totalObjectRefs, depth, bin.getBytesRead()));
totalObjectRefs, depth, bytesRead));
} catch (RuntimeException e) {
// Preventive interception of an exception to log
status = ObjectInputFilter.Status.REJECTED;
@ -1277,7 +1279,7 @@ public class ObjectInputStream
? Logger.Level.DEBUG
: Logger.Level.TRACE,
"ObjectInputFilter {0}: {1}, array length: {2}, nRefs: {3}, depth: {4}, bytes: {5}, ex: {6}",
status, clazz, arrayLength, totalObjectRefs, depth, bin.getBytesRead(),
status, clazz, arrayLength, totalObjectRefs, depth, bytesRead,
Objects.toString(ex, "n/a"));
}
if (status == null ||