提交 61f17936 编写于 作者: W weijun

8014341: Better service from Kerberos servers

Summary: read incoming data safely and take care of null return value
Reviewed-by: valeriep, ahgross
上级 71e9cefe
...@@ -246,11 +246,15 @@ public final class KdcComm { ...@@ -246,11 +246,15 @@ public final class KdcComm {
savedException = e; savedException = e;
} }
} }
if (ibuf == null && savedException != null) { if (ibuf == null) {
if (savedException instanceof IOException) { if (savedException != null) {
throw (IOException) savedException; if (savedException instanceof IOException) {
throw (IOException) savedException;
} else {
throw (KrbException) savedException;
}
} else { } else {
throw (KrbException) savedException; throw new IOException("Cannot get a KDC reply");
} }
} }
return ibuf; return ibuf;
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
package sun.security.krb5.internal; package sun.security.krb5.internal;
import sun.misc.IOUtils;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
...@@ -100,17 +102,15 @@ class TCPClient extends NetClient { ...@@ -100,17 +102,15 @@ class TCPClient extends NetClient {
return null; return null;
} }
byte data[] = new byte[len]; try {
count = readFully(data, len); return IOUtils.readFully(in, len, true);
if (count != len) { } catch (IOException ioe) {
if (Krb5.DEBUG) { if (Krb5.DEBUG) {
System.out.println( System.out.println(
">>>DEBUG: TCPClient could not read complete packet (" + ">>>DEBUG: TCPClient could not read complete packet (" +
len + "/" + count + ")"); len + "/" + count + ")");
} }
return null; return null;
} else {
return data;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册