summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ocsp/ocsp_ht.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/ocsp/ocsp_ht.c')
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_ht.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/lib/libcrypto/ocsp/ocsp_ht.c b/src/lib/libcrypto/ocsp/ocsp_ht.c
index b78cd37092..9213e58ae4 100644
--- a/src/lib/libcrypto/ocsp/ocsp_ht.c
+++ b/src/lib/libcrypto/ocsp/ocsp_ht.c
@@ -64,6 +64,9 @@
64#include <openssl/ocsp.h> 64#include <openssl/ocsp.h>
65#include <openssl/err.h> 65#include <openssl/err.h>
66#include <openssl/buffer.h> 66#include <openssl/buffer.h>
67#ifdef OPENSSL_SYS_SUNOS
68#define strtoul (unsigned long)strtol
69#endif /* OPENSSL_SYS_SUNOS */
67 70
68/* Quick and dirty HTTP OCSP request handler. 71/* Quick and dirty HTTP OCSP request handler.
69 * Could make this a bit cleverer by adding 72 * Could make this a bit cleverer by adding
@@ -94,7 +97,7 @@ Content-Length: %d\r\n\r\n";
94 } 97 }
95 if(!(mem = BIO_new(BIO_s_mem()))) goto err; 98 if(!(mem = BIO_new(BIO_s_mem()))) goto err;
96 /* Copy response to a memory BIO: socket bios can't do gets! */ 99 /* Copy response to a memory BIO: socket bios can't do gets! */
97 while ((len = BIO_read(b, tmpbuf, 1024))) { 100 while ((len = BIO_read(b, tmpbuf, sizeof tmpbuf))) {
98 if(len < 0) { 101 if(len < 0) {
99 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_READ_ERROR); 102 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_READ_ERROR);
100 goto err; 103 goto err;
@@ -107,7 +110,7 @@ Content-Length: %d\r\n\r\n";
107 } 110 }
108 /* Parse the HTTP response. This will look like this: 111 /* Parse the HTTP response. This will look like this:
109 * "HTTP/1.0 200 OK". We need to obtain the numeric code and 112 * "HTTP/1.0 200 OK". We need to obtain the numeric code and
110 * informational message. 113 * (optional) informational message.
111 */ 114 */
112 115
113 /* Skip to first white space (passed protocol info) */ 116 /* Skip to first white space (passed protocol info) */
@@ -135,13 +138,19 @@ Content-Length: %d\r\n\r\n";
135 if(*r) goto err; 138 if(*r) goto err;
136 /* Skip over any leading white space in message */ 139 /* Skip over any leading white space in message */
137 while(*q && isspace((unsigned char)*q)) q++; 140 while(*q && isspace((unsigned char)*q)) q++;
138 if(!*q) goto err; 141 if(*q) {
139 /* Finally zap any trailing white space in message (include CRLF) */ 142 /* Finally zap any trailing white space in message (include CRLF) */
140 /* We know q has a non white space character so this is OK */ 143 /* We know q has a non white space character so this is OK */
141 for(r = q + strlen(q) - 1; isspace((unsigned char)*r); r--) *r = 0; 144 for(r = q + strlen(q) - 1; isspace((unsigned char)*r); r--) *r = 0;
145 }
142 if(retcode != 200) { 146 if(retcode != 200) {
143 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_RESPONSE_ERROR); 147 OCSPerr(OCSP_F_OCSP_SENDREQ_BIO,OCSP_R_SERVER_RESPONSE_ERROR);
144 ERR_add_error_data(4, "Code=", p, ",Reason=", q); 148 if(!*q) {
149 ERR_add_error_data(2, "Code=", p);
150 }
151 else {
152 ERR_add_error_data(4, "Code=", p, ",Reason=", q);
153 }
145 goto err; 154 goto err;
146 } 155 }
147 /* Find blank line marking beginning of content */ 156 /* Find blank line marking beginning of content */