From a695599667df3907a7715d30855caf742def17cb Mon Sep 17 00:00:00 2001 From: John Safranek Date: Thu, 3 Jan 2013 17:58:45 -0800 Subject: [PATCH] bug fix in default ocsp lookup function --- src/io.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/io.c b/src/io.c index f8c738b50..d7b4fcb01 100644 --- a/src/io.c +++ b/src/io.c @@ -666,11 +666,22 @@ int EmbedOcspLookup(void* ctx, const char* url, int urlSz, byte* ocspReqBuf, int ocspReqSz, byte** ocspRespBuf) { char domainName[80], path[80]; - int port, ocspRespSz, httpBufSz, sfd; + int port, httpBufSz, sfd; + int ocspRespSz = 0; byte* httpBuf = NULL; (void)ctx; + if (ocspReqBuf == NULL || ocspReqSz == 0) { + CYASSL_MSG("OCSP request is required for lookup"); + return -1; + } + + if (ocspRespBuf == NULL) { + CYASSL_MSG("Cannot save OCSP response"); + return -1; + } + if (decode_url(url, urlSz, domainName, path, &port) < 0) { CYASSL_MSG("Unable to decode OCSP URL"); return -1; @@ -683,6 +694,7 @@ int EmbedOcspLookup(void* ctx, const char* url, int urlSz, CYASSL_MSG("Unable to create OCSP response buffer"); return -1; } + *ocspRespBuf = httpBuf; httpBufSz = build_http_request(domainName, path, ocspReqSz, httpBuf, httpBufSz);