61 lines
1.5 KiB
Diff
61 lines
1.5 KiB
Diff
https://github.com/voidlinux/xbps/issues/167
|
|
|
|
--- lib/fetch/common.c.orig 2016-04-23 07:06:15.548288496 +0200
|
|
+++ lib/fetch/common.c 2016-04-23 07:07:01.356794335 +0200
|
|
@@ -444,6 +444,7 @@ fetch_cache_put(conn_t *conn, int (*clos
|
|
|
|
|
|
#ifdef WITH_SSL
|
|
+
|
|
/*
|
|
* Find the first occurrence of find in s, where the search is limited to the
|
|
* first slen characters of s.
|
|
@@ -640,8 +641,10 @@ fetch_ssl_get_numeric_addrinfo(const cha
|
|
hints.ai_protocol = 0;
|
|
hints.ai_flags = AI_NUMERICHOST;
|
|
/* port is not relevant for this purpose */
|
|
- if (getaddrinfo(host, "443", &hints, &res) != 0)
|
|
+ if (getaddrinfo(host, "443", &hints, &res) != 0) {
|
|
+ free(host);
|
|
return NULL;
|
|
+ }
|
|
free(host);
|
|
return res;
|
|
}
|
|
@@ -929,8 +932,21 @@ fetch_ssl_cb_verify_crt(int verified, X5
|
|
return (verified);
|
|
}
|
|
|
|
+static pthread_once_t ssl_init_once = PTHREAD_ONCE_INIT;
|
|
+
|
|
+static void
|
|
+ssl_init(void)
|
|
+{
|
|
+ /* Init the SSL library and context */
|
|
+ if (!SSL_library_init()){
|
|
+ fprintf(stderr, "SSL library init failed\n");
|
|
+ exit(-1);
|
|
+ }
|
|
+ SSL_load_error_strings();
|
|
+}
|
|
#endif
|
|
|
|
+
|
|
/*
|
|
* Enable SSL on a connection.
|
|
*/
|
|
@@ -943,13 +959,7 @@ fetch_ssl(conn_t *conn, const struct url
|
|
X509_NAME *name;
|
|
char *str;
|
|
|
|
- /* Init the SSL library and context */
|
|
- if (!SSL_library_init()){
|
|
- fprintf(stderr, "SSL library init failed\n");
|
|
- return (-1);
|
|
- }
|
|
-
|
|
- SSL_load_error_strings();
|
|
+ (void)pthread_once(&ssl_init_once, ssl_init);
|
|
|
|
conn->ssl_meth = SSLv23_client_method();
|
|
conn->ssl_ctx = SSL_CTX_new(conn->ssl_meth);
|