Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/java.base/share/classes/sun/security/tools/keytool/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4305,11 +4305,9 @@ private void keystorecerts2Hashtable(KeyStore ks,
private static Date getStartDate(String s) throws IOException {
Calendar c = new GregorianCalendar();
if (s != null) {
IOException ioe = new IOException(
rb.getString("Illegal.startdate.value"));
int len = s.length();
if (len == 0) {
throw ioe;
throw new IOException(rb.getString("Illegal.startdate.value"));
}
if (s.charAt(0) == '-' || s.charAt(0) == '+') {
// Form 1: ([+-]nnn[ymdHMS])+
Expand All @@ -4319,16 +4317,16 @@ private static Date getStartDate(String s) throws IOException {
switch (s.charAt(start)) {
case '+': sign = 1; break;
case '-': sign = -1; break;
default: throw ioe;
default: throw new IOException(rb.getString("Illegal.startdate.value"));
}
int i = start+1;
for (; i<len; i++) {
char ch = s.charAt(i);
if (ch < '0' || ch > '9') break;
}
if (i == start+1) throw ioe;
if (i == start+1) throw new IOException(rb.getString("Illegal.startdate.value"));
int number = Integer.parseInt(s.substring(start+1, i));
if (i >= len) throw ioe;
if (i >= len) throw new IOException(rb.getString("Illegal.startdate.value"));
int unit;
switch (s.charAt(i)) {
case 'y': unit = Calendar.YEAR; break;
Expand All @@ -4337,7 +4335,7 @@ private static Date getStartDate(String s) throws IOException {
case 'H': unit = Calendar.HOUR; break;
case 'M': unit = Calendar.MINUTE; break;
case 'S': unit = Calendar.SECOND; break;
default: throw ioe;
default: throw new IOException(rb.getString("Illegal.startdate.value"));
}
c.add(unit, sign * number);
start = i + 1;
Expand All @@ -4349,21 +4347,21 @@ private static Date getStartDate(String s) throws IOException {
date = s.substring(0, 10);
time = s.substring(11);
if (s.charAt(10) != ' ')
throw ioe;
throw new IOException(rb.getString("Illegal.startdate.value"));
} else if (len == 10) {
date = s;
} else if (len == 8) {
time = s;
} else {
throw ioe;
throw new IOException(rb.getString("Illegal.startdate.value"));
}
if (date != null) {
if (date.matches("\\d\\d\\d\\d/\\d\\d/\\d\\d")) {
c.set(Integer.parseInt(date.substring(0, 4)),
Integer.parseInt(date.substring(5, 7))-1,
Integer.parseInt(date.substring(8, 10)));
} else {
throw ioe;
throw new IOException(rb.getString("Illegal.startdate.value"));
}
}
if (time != null) {
Expand All @@ -4373,7 +4371,7 @@ private static Date getStartDate(String s) throws IOException {
c.set(Calendar.SECOND, Integer.parseInt(time.substring(6, 8)));
c.set(Calendar.MILLISECOND, 0);
} else {
throw ioe;
throw new IOException(rb.getString("Illegal.startdate.value"));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ public void handshakeCompleted(HandshakeCompletedEvent event) {
} catch (SSLPeerUnverifiedException ex) {
CommunicationException ce = new CommunicationException();
ce.setRootCause(closureReason);
tlsHandshakeCompleted.completeExceptionally(ex);
tlsHandshakeCompleted.completeExceptionally(ce);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected static FileDescriptor newDescriptor(int fd) {
String str =
System.getProperty(PROP_FILE_DESCRIPTOR_CREATION_MODE, PROP_FILE_DESCRIPTOR_CREATION_MODE_DEFAULT);
String[] modes = str.split(",");
IllegalStateException ise = new IllegalStateException("Unable to create FileDescriptor");
IllegalStateException ise = null;
for (String mode : modes) {
try {
switch (mode) {
Expand All @@ -173,14 +173,17 @@ protected static FileDescriptor newDescriptor(int fd) {
}
} catch (Throwable t) {
// ignore
if (ise == null) {
ise = new IllegalStateException("Unable to create FileDescriptor");
}
ise.addSuppressed(t);
}
if (fileDescriptorCreator != null) {
break;
}
}
if (fileDescriptorCreator == null) {
throw ise;
throw ise != null ? ise : new IllegalStateException("Unable to create FileDescriptor");
}
}
return fileDescriptorCreator.newDescriptor(fd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ protected static ProcessBuilder.Redirect newDescriptor(FileDescriptor fd) {
if (redirectPipeCreator == null) {
String str = System.getProperty(PROP_REDIRECT_PIPE_CREATION_MODE, PROP_REDIRECT_PIPE_CREATION_MODE_DEFAULT);
String[] modes = str.split(",");
IllegalStateException ise = new IllegalStateException("Unable to create RedirectPipe");
IllegalStateException ise = null;
for (String mode : modes) {
try {
switch (mode) {
Expand All @@ -201,14 +201,17 @@ protected static ProcessBuilder.Redirect newDescriptor(FileDescriptor fd) {
}
} catch (Throwable t) {
// ignore
if (ise == null) {
ise = new IllegalStateException("Unable to create RedirectPipe");
}
ise.addSuppressed(t);
}
if (redirectPipeCreator != null) {
break;
}
}
if (redirectPipeCreator == null) {
throw ise;
throw ise != null ? ise : new IllegalStateException("Unable to create RedirectPipe");
}
}
return redirectPipeCreator.newRedirectPipe(fd);
Expand Down
13 changes: 7 additions & 6 deletions test/jdk/javax/net/ssl/TLSCommon/RehandshakeWithDataExTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,24 @@ protected void testOneCipher(String cipher) throws SSLException {
HandshakeMode.REHANDSHAKE_BEGIN_CLIENT);
sendApplicationData(clientEngine, serverEngine);
r = sendApplicationData(serverEngine, clientEngine);
AssertionError epochError = new AssertionError("Epoch number"
+ " did not grow after re-handshake! "
+ " Was " + initialEpoch + ", now " + secondEpoch + ".");
if (TESTED_SECURITY_PROTOCOL.contains("DTLS")) {
secondEpoch = r.sequenceNumber() >> 48;
if (Long.compareUnsigned(secondEpoch, initialEpoch) <= 0) {
throw epochError;
throw new AssertionError("Epoch number"
+ " did not grow after re-handshake! "
+ " Was " + initialEpoch + ", now " + secondEpoch + ".");
}
}
doHandshake(clientEngine, serverEngine, maxPacketSize,
HandshakeMode.REHANDSHAKE_BEGIN_SERVER);
sendApplicationData(clientEngine, serverEngine);
r = sendApplicationData(serverEngine, clientEngine);
if (TESTED_SECURITY_PROTOCOL.contains("DTLS")) {
thirdEpoch = r.sequenceNumber() >> 48;
thirdEpoch = r.sequenceNumber() >> 48;
if (Long.compareUnsigned(thirdEpoch, secondEpoch) <= 0) {
throw epochError;
throw new AssertionError("Epoch number"
+ " did not grow after re-handshake! "
+ " Was " + secondEpoch + ", now " + thirdEpoch + ".");
}
}
closeEngines(clientEngine, serverEngine);
Expand Down