--- a/jdk/src/share/classes/sun/security/provider/certpath/OCSPChecker.java Tue Jun 30 11:13:51 2009 +0100
+++ b/jdk/src/share/classes/sun/security/provider/certpath/OCSPChecker.java Fri Jul 03 11:13:42 2009 +0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. 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
@@ -351,18 +351,27 @@
}
in = con.getInputStream();
+ byte[] response = null;
+ int total = 0;
int contentLength = con.getContentLength();
- if (contentLength == -1) {
+ if (contentLength != -1) {
+ response = new byte[contentLength];
+ } else {
+ response = new byte[2048];
contentLength = Integer.MAX_VALUE;
}
- byte[] response = new byte[contentLength];
- int total = 0;
- int count = 0;
- while (count != -1 && total < contentLength) {
- count = in.read(response, total, response.length - total);
+ while (total < contentLength) {
+ int count = in.read(response, total, response.length - total);
+ if (count < 0)
+ break;
+
total += count;
+ if (total >= response.length && total < contentLength) {
+ response = Arrays.copyOf(response, total * 2);
+ }
}
+ response = Arrays.copyOf(response, total);
OCSPResponse ocspResponse = new OCSPResponse(response, pkixParams,
responderCert);