xbps: apply changes from master to fix multiple issues.

- https://github.com/voidlinux/xbps/issues/167
- https://github.com/voidlinux/xbps/issues/170
- xbps-install/xbps-query line truncation with musl
This commit is contained in:
Juan RP 2016-04-24 19:28:05 +02:00
parent 087e9cd71b
commit c60d3379fd
5 changed files with 97 additions and 62 deletions

View file

@ -0,0 +1,74 @@
--- lib/fetch/common.c.orig 2016-04-24 19:23:10.086252434 +0200
+++ lib/fetch/common.c 2016-04-24 19:23:38.375203346 +0200
@@ -444,6 +444,8 @@ fetch_cache_put(conn_t *conn, int (*clos
#ifdef WITH_SSL
+
+#ifndef HAVE_STRNSTR
/*
* Find the first occurrence of find in s, where the search is limited to the
* first slen characters of s.
@@ -468,6 +470,7 @@ strnstr(const char *s, const char *find,
}
return ((char *)__UNCONST(s));
}
+#endif
/*
* Convert characters A-Z to lowercase (intentionally avoid any locale
@@ -640,8 +643,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 +934,18 @@ 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 */
+ SSL_load_error_strings();
+ SSL_library_init();
+}
#endif
+
/*
* Enable SSL on a connection.
*/
@@ -943,16 +958,14 @@ 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);
+ conn->ssl_ctx = SSL_CTX_new(SSLv23_client_method());
+ if (conn->ssl_ctx == NULL) {
+ fprintf(stderr, "failed to create SSL context\n");
+ ERR_print_errors_fp(stderr);
+ return -1;
+ }
SSL_CTX_set_mode(conn->ssl_ctx, SSL_MODE_AUTO_RETRY);
fetch_ssl_setup_transport_layer(conn->ssl_ctx, verbose);

View file

@ -0,0 +1,11 @@
--- lib/pubkey2fp.c.orig 2016-04-24 19:27:07.063791995 +0200
+++ lib/pubkey2fp.c 2016-04-24 19:27:11.295783820 +0200
@@ -160,8 +160,5 @@ out:
if (pEncoding)
free(pEncoding);
- EVP_cleanup();
- ERR_free_strings();
-
return hexfpstr;
}

View file

@ -1,61 +0,0 @@
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);

View file

@ -0,0 +1,11 @@
--- bin/xbps-install/util.c.orig 2016-04-24 19:23:18.366238066 +0200
+++ bin/xbps-install/util.c 2016-04-24 19:23:29.454218826 +0200
@@ -41,7 +41,7 @@ get_maxcols(void)
{
struct winsize ws;
- if (!isatty(STDOUT_FILENO) && errno == ENOTTY) {
+ if (!isatty(STDOUT_FILENO)) {
/* not a TTY, don't use any limit */
return 0;
}

View file

@ -1,7 +1,7 @@
# Template file for 'xbps'
pkgname=xbps
version=0.51
revision=5
revision=6
bootstrap=yes
build_style=configure
short_desc="The XBPS package system utilities"