From 22636a6893a23e1485d92458e48585d0d3960e6b Mon Sep 17 00:00:00 2001 From: Christos Tsantilas Date: Thu, 20 Sep 2012 21:17:40 +0300 Subject: [PATCH] run formatter --- src/forward.cc | 8 +++---- src/forward.h | 4 ++-- src/ssl/cert_validate_message.cc | 36 +++++++++++++++++--------------- src/ssl/cert_validate_message.h | 23 ++++++++++++-------- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/forward.cc b/src/forward.cc index af364c56ec..8731dc7f9c 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -765,8 +765,8 @@ FwdState::negotiateSSL(int fd) // WARNING: The STACK_OF(*) OpenSSL objects does not support locking. // If we need to support locking we need to sk_X509_dup the STACK_OF(X509) // list and lock all of the X509 members of the list. - // Currently we do not use any locking for any of the members of the - // Ssl::CertValidationRequest class. If the ssl object gone, the value returned + // Currently we do not use any locking for any of the members of the + // Ssl::CertValidationRequest class. If the ssl object gone, the value returned // from SSL_get_peer_cert_chain may not exist any more. In this code the // Ssl::CertValidationRequest object used only to pass data to // Ssl::CertValidationHelper::submit method. @@ -834,7 +834,7 @@ FwdState::sslCrtvdHandleReply(const char *reply) std::string error; STACK_OF(X509) *peerCerts = SSL_get_peer_cert_chain(ssl); if (replyMsg.parse(reply, strlen(reply)) != Ssl::CrtdMessage::OK || - !replyMsg.parseResponse(validationResponse, peerCerts, error) ) { + !replyMsg.parseResponse(validationResponse, peerCerts, error) ) { debugs(83, 5, HERE << "Reply from ssl_crtvd for " << request->GetHost() << " is incorrect"); validatorFailed = true; } else { @@ -930,7 +930,7 @@ FwdState::sslCrtvdCheckForErrors(Ssl::CertValidationResponse &resp, Ssl::ErrorDe if (!errs) errs = new Ssl::Errors(i->error_no); - else + else errs->push_back_unique(i->error_no); } diff --git a/src/forward.h b/src/forward.h index 30200ad4a3..b0bae5e3da 100644 --- a/src/forward.h +++ b/src/forward.h @@ -21,8 +21,8 @@ class HttpRequest; #if USE_SSL namespace Ssl { - class ErrorDetail; - class CertValidationResponse; +class ErrorDetail; +class CertValidationResponse; }; #endif diff --git a/src/ssl/cert_validate_message.cc b/src/ssl/cert_validate_message.cc index 967c8239b6..7567c35bd4 100644 --- a/src/ssl/cert_validate_message.cc +++ b/src/ssl/cert_validate_message.cc @@ -4,7 +4,6 @@ #include "ssl/cert_validate_message.h" #include "ssl/ErrorDetail.h" - void Ssl::CertValidationMsg::composeRequest(CertValidationRequest const &vcert) { @@ -56,8 +55,8 @@ Ssl::CertValidationMsg::parseResponse(CertValidationResponse &resp, STACK_OF(X50 std::vector certs; const char *param = body.c_str(); - while(*param) { - while(xisspace(*param)) param++; + while (*param) { + while (xisspace(*param)) param++; if (! *param) break; @@ -68,10 +67,10 @@ Ssl::CertValidationMsg::parseResponse(CertValidationResponse &resp, STACK_OF(X50 } const char *value=param+param_len+1; - if (param_len > param_cert.length() && - strncmp(param, param_cert.c_str(), param_cert.length()) == 0) { + if (param_len > param_cert.length() && + strncmp(param, param_cert.c_str(), param_cert.length()) == 0) { CertItem ci; - ci.name.assign(param, param_len); + ci.name.assign(param, param_len); X509_Pointer x509; readCertFromMemory(x509, value); ci.setCert(x509.get()); @@ -90,20 +89,20 @@ Ssl::CertValidationMsg::parseResponse(CertValidationResponse &resp, STACK_OF(X50 size_t value_len = strcspn(value, "\r\n"); std::string v(value, value_len); - debugs(83, 5, HERE << "Returned value: " << std::string(param, param_len).c_str() << ": " << + debugs(83, 5, HERE << "Returned value: " << std::string(param, param_len).c_str() << ": " << v.c_str()); int errorId = get_error_id(param, param_len); Ssl::CertValidationResponse::RecvdError ¤tItem = resp.getError(errorId); - if (param_len > param_error_name.length() && - strncmp(param, param_error_name.c_str(), param_error_name.length()) == 0){ + if (param_len > param_error_name.length() && + strncmp(param, param_error_name.c_str(), param_error_name.length()) == 0) { currentItem.error_no = Ssl::GetErrorCode(v.c_str()); if (currentItem.error_no == SSL_ERROR_NONE) { debugs(83, 2, "Cert validator response parse error: Unknown SSL Error: " << v); return false; } - } else if (param_len > param_error_reason.length() && + } else if (param_len > param_error_reason.length() && strncmp(param, param_error_reason.c_str(), param_error_reason.length()) == 0) { currentItem.error_reason = v; } else if (param_len > param_error_cert.length() && @@ -126,7 +125,6 @@ Ssl::CertValidationMsg::parseResponse(CertValidationResponse &resp, STACK_OF(X50 debugs(83, 2, "Cert validator response parse error: Unknown parameter name " << std::string(param, param_len).c_str()); return false; } - param = value + value_len +1; } @@ -151,7 +149,7 @@ Ssl::CertValidationResponse::RecvdError & Ssl::CertValidationResponse::getError(int errorId) { typedef Ssl::CertValidationResponse::RecvdErrors::iterator SVCREI; - for(SVCREI i = errors.begin(); i != errors.end(); ++i){ + for (SVCREI i = errors.begin(); i != errors.end(); ++i) { if (i->id == errorId) return *i; } @@ -161,19 +159,22 @@ Ssl::CertValidationResponse::getError(int errorId) return errors.back(); } -Ssl::CertValidationResponse::RecvdError::RecvdError(const RecvdError &old) { +Ssl::CertValidationResponse::RecvdError::RecvdError(const RecvdError &old) +{ error_no = old.error_no; error_reason = old.error_reason; cert = NULL; setCert(old.cert); } -Ssl::CertValidationResponse::RecvdError::~RecvdError() { +Ssl::CertValidationResponse::RecvdError::~RecvdError() +{ if (cert) X509_free(cert); } -Ssl::CertValidationResponse::RecvdError & Ssl::CertValidationResponse::RecvdError::operator = (const RecvdError &old) { +Ssl::CertValidationResponse::RecvdError & Ssl::CertValidationResponse::RecvdError::operator = (const RecvdError &old) +{ error_no = old.error_no; error_reason = old.error_reason; setCert(old.cert); @@ -181,7 +182,8 @@ Ssl::CertValidationResponse::RecvdError & Ssl::CertValidationResponse::RecvdErro } void -Ssl::CertValidationResponse::RecvdError::setCert(X509 *aCert) { +Ssl::CertValidationResponse::RecvdError::setCert(X509 *aCert) +{ if (cert) X509_free(cert); if (aCert) { @@ -227,7 +229,7 @@ const std::string Ssl::CertValidationMsg::code_cert_validate("cert_validate"); const std::string Ssl::CertValidationMsg::param_domain("domain"); const std::string Ssl::CertValidationMsg::param_error("errors"); const std::string Ssl::CertValidationMsg::param_cert("cert_"); -const std::string Ssl::CertValidationMsg::param_error_name("error_name_"); +const std::string Ssl::CertValidationMsg::param_error_name("error_name_"); const std::string Ssl::CertValidationMsg::param_error_reason("error_reason_"); const std::string Ssl::CertValidationMsg::param_error_cert("error_cert_"); diff --git a/src/ssl/cert_validate_message.h b/src/ssl/cert_validate_message.h index 99e1982a6a..3d22aa64a9 100644 --- a/src/ssl/cert_validate_message.h +++ b/src/ssl/cert_validate_message.h @@ -9,14 +9,15 @@ #include "ssl/crtd_message.h" #include -namespace Ssl +namespace Ssl { /** * This class is used to hold the required informations to build * a request message for the certificate validator helper */ -class CertValidationRequest { +class CertValidationRequest +{ public: STACK_OF(X509) *peerCerts; ///< The list of sent by SSL server Errors *errors; ///< The list of errors detected @@ -28,13 +29,15 @@ public: * This class is used to store informations found in certificate validation * response messages read from certificate validator helper */ -class CertValidationResponse { +class CertValidationResponse +{ public: /** * This class used to hold error informations returned from * cert validator helper. */ - class RecvdError{ + class RecvdError + { public: RecvdError(): id(0), error_no(SSL_ERROR_NONE), cert(NULL) {} RecvdError(const RecvdError &); @@ -61,13 +64,15 @@ public: * The messages format is: * ...\1 */ -class CertValidationMsg: public CrtdMessage { +class CertValidationMsg: public CrtdMessage +{ private: /** * This class used to hold the certId/cert pairs found * in cert validation messages. */ - class CertItem { + class CertItem + { public: std::string name; ///< The certificate Id to use X509 *cert; ///< A pointer to certificate @@ -98,11 +103,11 @@ public: /// Parameter name for passing SSL errors static const std::string param_error; /// Parameter name for passing SSL certificates - static const std::string param_cert; + static const std::string param_cert; /// Parameter name for passing the major SSL error - static const std::string param_error_name; + static const std::string param_error_name; /// Parameter name for passing the error reason - static const std::string param_error_reason; + static const std::string param_error_reason; /// Parameter name for passing the error cert ID static const std::string param_error_cert; }; -- 2.47.2