]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
Gisle made the code use ERR_error_string_n()
authorDaniel Stenberg <daniel@haxx.se>
Thu, 29 Apr 2004 07:36:40 +0000 (07:36 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 29 Apr 2004 07:36:40 +0000 (07:36 +0000)
lib/ssluse.c

index fa8a9fc8090a1c877366faa67c6266e8f8ef5f18..c27eb918c0d344ff22d0776753dce14bf1c950ee 100644 (file)
 #undef HAVE_ENGINE_LOAD_FOUR_ARGS
 #endif
 
+#if OPENSSL_VERSION_NUMBER >= 0x00906001L
+#define HAVE_ERR_ERROR_STRING_N 1
+#endif
+
 
 #ifndef HAVE_USERDATA_IN_PWD_CALLBACK
 static char global_passwd[64];
@@ -383,21 +387,17 @@ int cert_verify_callback(int ok, X509_STORE_CTX *ctx)
   char buf[256];
 
   err_cert=X509_STORE_CTX_get_current_cert(ctx);
-  X509_NAME_oneline(X509_get_subject_name(err_cert),buf,256);
-
+  X509_NAME_oneline(X509_get_subject_name(err_cert), buf, sizeof(buf));
   return ok;
 }
 
-#endif
-
-#ifdef USE_SSLEAY
 /* "global" init done? */
 static int init_ssl=0;
 
 /* we have the "SSL is seeded" boolean global for the application to
    prevent multiple time-consuming seedings in vain */
 static bool ssl_seeded = FALSE;
-#endif
+#endif /* USE_SSLEAY */
 
 /* Global init */
 void Curl_SSL_init(void)
@@ -1141,11 +1141,16 @@ Curl_SSLConnect(struct connectdata *conn,
           return CURLE_SSL_CACERT;
         default:
           /* detail is already set to the SSL error above */
-          failf(data, "SSL: %s", ERR_error_string(errdetail, error_buffer));
+#ifdef HAVE_ERR_ERROR_STRING_N
           /* OpenSSL 0.9.6 and later has a function named
-             ERRO_error_string_n() that takes the size of the buffer as a third
-             argument, and we should possibly switch to using that one in the
-             future. */
+             ERRO_error_string_n() that takes the size of the buffer as a
+             third argument */
+          ERR_error_string_n(errdetail, error_buffer, sizeof(error_buffer));
+#else
+          ERR_error_string(errdetail, error_buffer);
+#endif
+
+          failf(data, "SSL: %s", error_buffer);
           return CURLE_SSL_CONNECT_ERROR;
         }
       }