pcrs: Request JIT compilation if it's supported
[privoxy.git] / ssl.c
diff --git a/ssl.c b/ssl.c
index 6eb5945..bc4c5af 100644 (file)
--- a/ssl.c
+++ b/ssl.c
@@ -105,7 +105,7 @@ static int seed_rng(struct client_state *csp);
  *                or has not yet been sent by the remote end.
  *
  * Parameters  :
- *          1  :  ssl = SSL context to test
+ *          1  :  ssl_attr = SSL context to test
  *
  * Returns     :   0 => No data are pending
  *                >0 => Pending data length
@@ -131,7 +131,7 @@ extern size_t is_ssl_pending(struct ssl_attr *ssl_attr)
  *                connection context.
  *
  * Parameters  :
- *          1  :  ssl = SSL context to send data to
+ *          1  :  ssl_attr = SSL context to send data to
  *          2  :  buf = Pointer to data to be sent
  *          3  :  len = Length of data to be sent to the SSL context
  *
@@ -206,7 +206,7 @@ extern int ssl_send_data(struct ssl_attr *ssl_attr, const unsigned char *buf, si
  *                it into buffer.
  *
  * Parameters  :
- *          1  :  ssl = SSL context to receive data from
+ *          1  :  ssl_attr = SSL context to receive data from
  *          2  :  buf = Pointer to buffer where data will be written
  *          3  :  max_length = Maximum number of bytes to read
  *
@@ -252,34 +252,6 @@ extern int ssl_recv_data(struct ssl_attr *ssl_attr, unsigned char *buf, size_t m
 }
 
 
-/*********************************************************************
- *
- * Function    :  ssl_debug_callback
- *
- * Description :  Debug callback function for mbedtls library.
- *                Prints info into log file.
- *
- * Parameters  :
- *          1  :  ctx   = File to save log in
- *          2  :  level = Debug level
- *          3  :  file  = File calling debug message
- *          4  :  line  = Line calling debug message
- *          5  :  str   = Debug message
- *
- * Returns     :  N/A
- *
- *********************************************************************/
-static void ssl_debug_callback(void *ctx, int level, const char *file, int line, const char *str)
-{
-   /*
-   ((void)level);
-   fprintf((FILE *)ctx, "%s:%04d: %s", file, line, str);
-   fflush((FILE *)ctx);
-   log_error(LOG_LEVEL_INFO, "SSL debug message: %s:%04d: %s", file, line, str);
-   */
-}
-
-
 /*********************************************************************
  *
  * Function    :  create_client_ssl_connection
@@ -422,8 +394,6 @@ extern int create_client_ssl_connection(struct client_state *csp)
 
    mbedtls_ssl_conf_rng(&(ssl_attr->mbedtls_attr.conf),
       mbedtls_ctr_drbg_random, &ctr_drbg);
-   mbedtls_ssl_conf_dbg(&(ssl_attr->mbedtls_attr.conf),
-      ssl_debug_callback, stdout);
 
 #if defined(MBEDTLS_SSL_CACHE_C)
    mbedtls_ssl_conf_session_cache(&(ssl_attr->mbedtls_attr.conf),
@@ -677,8 +647,6 @@ extern int create_server_ssl_connection(struct client_state *csp)
 
    mbedtls_ssl_conf_rng(&(ssl_attr->mbedtls_attr.conf),
       mbedtls_ctr_drbg_random, &ctr_drbg);
-   mbedtls_ssl_conf_dbg(&(ssl_attr->mbedtls_attr.conf),
-      ssl_debug_callback, stdout);
 
    ret = mbedtls_ssl_setup(&(ssl_attr->mbedtls_attr.ssl),
       &(ssl_attr->mbedtls_attr.conf));
@@ -1726,6 +1694,12 @@ static int ssl_verify_callback(void *csp_void, mbedtls_x509_crt *crt,
 
       mbedtls_x509_crt_info(buf, sizeof(buf), CERT_INFO_PREFIX, crt);
       encoded_text = html_encode(buf);
+      if (encoded_text == NULL)
+      {
+         log_error(LOG_LEVEL_ERROR,
+            "Failed to HTML-encode the certificate information");
+         return -1;
+      }
       strlcpy(last->info_buf, encoded_text, sizeof(last->info_buf));
       freez(encoded_text);
    }
@@ -1835,7 +1809,7 @@ static int seed_rng(struct client_state *csp)
  *
  *********************************************************************/
 extern int ssl_base64_encode(unsigned char *dst, size_t dlen, size_t *olen,
-                              const unsigned char *src, size_t slen )
+                             const unsigned char *src, size_t slen)
 {
    return mbedtls_base64_encode(dst, dlen, olen, src, slen);
 }