ssl_send_data(): Prevent endless loop
[privoxy.git] / openssl.c
index a2d8853..6cc2af5 100644 (file)
--- a/openssl.c
+++ b/openssl.c
@@ -1,6 +1,6 @@
 /*********************************************************************
  *
- * File        :  $Source: $
+ * File        :  $Source: /cvsroot/ijbswa/current/openssl.c,v $
  *
  * Purpose     :  File with TLS/SSL extension. Contains methods for
  *                creating, using and closing TLS/SSL connections.
@@ -171,7 +171,7 @@ extern int ssl_send_data(struct ssl_attr *ssl_attr, const unsigned char *buf, si
        */
       while ((ret = BIO_write(bio,
          (const unsigned char *)(buf + pos),
-         send_len)) < 0)
+         send_len)) <= 0)
       {
          if (!BIO_should_retry(bio))
          {
@@ -416,7 +416,7 @@ static int ssl_store_cert(struct client_state *csp, X509* crt)
 
    if (BIO_puts(bio, "\nsubject name      : ") <= 0)
    {
-      log_ssl_errors(LOG_LEVEL_ERROR, "BIO_puts() for sublect failed");
+      log_ssl_errors(LOG_LEVEL_ERROR, "BIO_puts() for subject failed");
       ret = -1;
       goto exit;
    }
@@ -821,7 +821,8 @@ extern int create_client_ssl_connection(struct client_state *csp)
       csp->http->hash_of_host_hex);
    if (BIO_do_handshake(ssl_attr->openssl_attr.bio) != 1)
    {
-       log_ssl_errors(LOG_LEVEL_ERROR, "BIO_do_handshake failed");
+       log_ssl_errors(LOG_LEVEL_ERROR,
+          "The TLS/SSL handshake with the client failed");
        ret = -1;
        goto exit;
    }
@@ -1054,7 +1055,8 @@ extern int create_server_ssl_connection(struct client_state *csp)
 
    if (BIO_do_handshake(ssl_attrs->bio) != 1)
    {
-      log_ssl_errors(LOG_LEVEL_ERROR, "BIO_do_handshake failed");
+      log_ssl_errors(LOG_LEVEL_ERROR,
+         "The TLS/SSL handshake with the server failed");
       ret = -1;
       goto exit;
    }
@@ -1170,11 +1172,11 @@ static void log_ssl_errors(int debuglevel, const char* fmt, ...)
    va_end(args);
    /*
     * In case if called by mistake and there were
-    * no SSL errors let's report it to the log.
+    * no TLS/SSL errors let's report it to the log.
     */
    if (!reported)
    {
-      log_error(debuglevel, "%s: no ssl errors detected", prefix);
+      log_error(debuglevel, "%s: no TLS/SSL errors detected", prefix);
    }
 }