From e050eec7d4fb4f96233b55b9cfdc75ff2bccda11 Mon Sep 17 00:00:00 2001 From: Max Parmer Date: Mon, 21 Mar 2016 20:43:33 -0700 Subject: Removes third-party libstrophe patches. --- .../files/libstrophe-fix-crash-on-non-latin1.patch | 20 ---- .../libstrophe-fix-memory-leak-in-logging.patch | 64 ----------- .../files/libstrophe-fix-memory-leaks.patch | 56 ---------- .../libstrophe/files/libstrophe-xml-escape.patch | 121 --------------------- .../files/libstrophe-xmpp-conn-disable-tls.patch | 84 -------------- 5 files changed, 345 deletions(-) delete mode 100644 dev-libs/libstrophe/files/libstrophe-fix-crash-on-non-latin1.patch delete mode 100644 dev-libs/libstrophe/files/libstrophe-fix-memory-leak-in-logging.patch delete mode 100644 dev-libs/libstrophe/files/libstrophe-fix-memory-leaks.patch delete mode 100644 dev-libs/libstrophe/files/libstrophe-xml-escape.patch delete mode 100644 dev-libs/libstrophe/files/libstrophe-xmpp-conn-disable-tls.patch diff --git a/dev-libs/libstrophe/files/libstrophe-fix-crash-on-non-latin1.patch b/dev-libs/libstrophe/files/libstrophe-fix-crash-on-non-latin1.patch deleted file mode 100644 index 41699ad..0000000 --- a/dev-libs/libstrophe/files/libstrophe-fix-crash-on-non-latin1.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/src/hash.c b/src/hash.c -index 27d2756..111149a 100644 ---- a/src/hash.c -+++ b/src/hash.c -@@ -109,13 +109,13 @@ void hash_release(hash_t * const table) - /** hash a key for our table lookup */ - static int _hash_key(hash_t *table, const char *key) - { -- int hash = 0; -+ unsigned int hash = 0; - int shift = 0; - const char *c = key; - - while (*c != '\0') { - /* assume 32 bit ints */ -- hash ^= ((int)*c++ << shift); -+ hash ^= ((unsigned int)*c++ << shift); - shift += 8; - if (shift > 24) shift = 0; - } diff --git a/dev-libs/libstrophe/files/libstrophe-fix-memory-leak-in-logging.patch b/dev-libs/libstrophe/files/libstrophe-fix-memory-leak-in-logging.patch deleted file mode 100644 index 4537d8f..0000000 --- a/dev-libs/libstrophe/files/libstrophe-fix-memory-leak-in-logging.patch +++ /dev/null @@ -1,64 +0,0 @@ -diff --git a/src/ctx.c b/src/ctx.c -index 48e87ad..5a24687 100644 ---- a/src/ctx.c -+++ b/src/ctx.c -@@ -249,30 +249,38 @@ void xmpp_log(const xmpp_ctx_t * const ctx, - { - int oldret, ret; - char smbuf[1024]; -- char *buf; -- va_list copy; -+ char *bigbuf = NULL; -+ va_list ap_copy; - -- buf = smbuf; -- va_copy(copy, ap); -- ret = xmpp_vsnprintf(buf, 1023, fmt, ap); -+ va_copy(ap_copy, ap); -+ ret = xmpp_vsnprintf(smbuf, 1023, fmt, ap_copy); -+ va_end(ap_copy); - if (ret > 1023) { -- va_copy(ap, copy); -- buf = (char *)xmpp_alloc(ctx, ret + 1); -- if (!buf) { -- buf = NULL; -- xmpp_error(ctx, "log", "Failed allocating memory for log message."); -- return; -- } -- oldret = ret; -- ret = xmpp_vsnprintf(buf, ret + 1, fmt, ap); -- if (ret > oldret) { -- xmpp_error(ctx, "log", "Unexpected error"); -- return; -- } -+ bigbuf = (char *)xmpp_alloc(ctx, ret + 1); -+ if (!bigbuf) { -+ bigbuf = NULL; -+ xmpp_error(ctx, "log", "Failed allocating memory for log message."); -+ return; -+ } -+ oldret = ret; -+ va_copy(ap_copy, ap); -+ ret = xmpp_vsnprintf(bigbuf, ret + 1, fmt, ap_copy); -+ va_end(ap_copy); -+ -+ if (ret > oldret) { -+ xmpp_error(ctx, "log", "Unexpected error"); -+ return; -+ } -+ -+ if (ctx->log->handler) { -+ ctx->log->handler(ctx->log->userdata, level, area, bigbuf); -+ } -+ xmpp_free(ctx, bigbuf); -+ } else { -+ if (ctx->log->handler) { -+ ctx->log->handler(ctx->log->userdata, level, area, smbuf); -+ } - } -- -- if (ctx->log->handler) -- ctx->log->handler(ctx->log->userdata, level, area, buf); - } - - /** Write to the log at the ERROR level. diff --git a/dev-libs/libstrophe/files/libstrophe-fix-memory-leaks.patch b/dev-libs/libstrophe/files/libstrophe-fix-memory-leaks.patch deleted file mode 100644 index 60bb02c..0000000 --- a/dev-libs/libstrophe/files/libstrophe-fix-memory-leaks.patch +++ /dev/null @@ -1,56 +0,0 @@ -diff --git a/src/auth.c b/src/auth.c -index 2371925..30d0832 100644 ---- a/src/auth.c -+++ b/src/auth.c -@@ -554,6 +554,7 @@ static void _auth(xmpp_conn_t * const conn) - disconnect_mem_error(conn); - return; - } -+ xmpp_free(conn->ctx, authid); - xmpp_stanza_set_text(authdata, str); - xmpp_free(conn->ctx, str); - -diff --git a/src/conn.c b/src/conn.c -index 26df418..cf29744 100644 ---- a/src/conn.c -+++ b/src/conn.c -@@ -190,6 +190,8 @@ int xmpp_conn_release(xmpp_conn_t * const conn) - xmpp_connlist_t *item, *prev; - xmpp_handlist_t *hlitem, *thli; - hash_iterator_t *iter; -+ xmpp_send_queue_t *sq; -+ xmpp_send_queue_t *tsq; - const char *key; - int released = 0; - -@@ -267,13 +269,28 @@ int xmpp_conn_release(xmpp_conn_t * const conn) - } - - parser_free(conn->parser); -- -+ - if (conn->domain) xmpp_free(ctx, conn->domain); - if (conn->jid) xmpp_free(ctx, conn->jid); -- if (conn->bound_jid) xmpp_free(ctx, conn->bound_jid); -+ if (conn->bound_jid) xmpp_free(ctx, conn->bound_jid); - if (conn->pass) xmpp_free(ctx, conn->pass); - if (conn->stream_id) xmpp_free(ctx, conn->stream_id); - if (conn->lang) xmpp_free(ctx, conn->lang); -+ -+ sq = conn->send_queue_head; -+ while (sq != NULL) { -+ if (sq->data) { -+ xmpp_free(ctx, sq->data); -+ } -+ tsq = sq->next; -+ xmpp_free(ctx, sq); -+ sq = tsq; -+ } -+ -+ if (conn->tls) { -+ tls_free(conn->tls); -+ } -+ - xmpp_free(ctx, conn); - released = 1; - } diff --git a/dev-libs/libstrophe/files/libstrophe-xml-escape.patch b/dev-libs/libstrophe/files/libstrophe-xml-escape.patch deleted file mode 100644 index 4b97099..0000000 --- a/dev-libs/libstrophe/files/libstrophe-xml-escape.patch +++ /dev/null @@ -1,121 +0,0 @@ -commit c0b1e5b7fe51c6b7018116d96ea98b7912374385 -Author: Alexandre Erwin Ittner -Date: Sun Sep 23 17:18:53 2012 -0300 - - Fix escaping of XML text and attributes - - There was a bug in xmpp_send which caused XML special characters to be - sent to the server verbatim, implying in invalid stanzas and making the - server drop the connection. This commit fixed the bug escaping such - characters with the usual rules. - - Bugs: The code now do several (de)allocation operations in every send, - this may have a negative effect on performance when used with slow - memory managers. - - License: This code is distributed under the same license used by strophe - (i.e., GPLv3 or MIT). - -diff --git a/src/stanza.c b/src/stanza.c -index 6bf11b8..4ecc558 100644 ---- a/src/stanza.c -+++ b/src/stanza.c -@@ -206,6 +206,64 @@ int xmpp_stanza_is_tag(xmpp_stanza_t * const stanza) - return (stanza && stanza->type == XMPP_STANZA_TAG); - } - -+/* Escape a string with for use in a XML text node or attribute. Assumes that -+ * the input string is encoded in UTF-8. On sucess, returns a pointer to a -+ * buffer with the resulting data which must be xmpp_free()'d by the caller. -+ * On failure, returns NULL. -+ */ -+ -+static char *_escape_xml(xmpp_ctx_t * const ctx, char *text) -+{ -+ size_t len = 0; -+ char *src; -+ char *dst; -+ char *buf; -+ for (src = text; *src != '\0'; src++) { -+ switch (*src) { -+ case '<': /* "<" */ -+ case '>': /* ">" */ -+ len += 4; -+ break; -+ case '&': /* "&" */ -+ len += 5; -+ break; -+ case '"': -+ len += 6; /*""" */ -+ break; -+ default: -+ len++; -+ } -+ } -+ if ((buf = xmpp_alloc(ctx, (len+1) * sizeof(char))) == NULL) -+ return NULL; /* Error */ -+ dst = buf; -+ for (src = text; *src != '\0'; src++) { -+ switch (*src) { -+ case '<': -+ strcpy(dst, "<"); -+ dst += 4; -+ break; -+ case '>': -+ strcpy(dst, ">"); -+ dst += 4; -+ break; -+ case '&': -+ strcpy(dst, "&"); -+ dst += 5; -+ break; -+ case '"': -+ strcpy(dst, """); -+ dst += 6; -+ break; -+ default: -+ *dst = *src; -+ dst++; -+ } -+ } -+ *dst = '\0'; -+ return buf; -+} -+ - /* small helper function */ - static inline void _render_update(int *written, const int length, - const int lastwrite, -@@ -236,6 +294,7 @@ static int _render_stanza_recursive(xmpp_stanza_t *stanza, - xmpp_stanza_t *child; - hash_iterator_t *iter; - const char *key; -+ char *tmp; - - written = 0; - -@@ -244,7 +303,10 @@ static int _render_stanza_recursive(xmpp_stanza_t *stanza, - if (stanza->type == XMPP_STANZA_TEXT) { - if (!stanza->data) return XMPP_EINVOP; - -- ret = xmpp_snprintf(ptr, left, "%s", stanza->data); -+ tmp = _escape_xml(stanza->ctx, stanza->data); -+ if (tmp == NULL) return XMPP_EMEM; -+ ret = xmpp_snprintf(ptr, left, "%s", tmp); -+ xmpp_free(stanza->ctx, tmp); - if (ret < 0) return XMPP_EMEM; - _render_update(&written, buflen, ret, &left, &ptr); - } else { /* stanza->type == XMPP_STANZA_TAG */ -@@ -258,8 +320,11 @@ static int _render_stanza_recursive(xmpp_stanza_t *stanza, - if (stanza->attributes && hash_num_keys(stanza->attributes) > 0) { - iter = hash_iter_new(stanza->attributes); - while ((key = hash_iter_next(iter))) { -- ret = xmpp_snprintf(ptr, left, " %s=\"%s\"", key, -- (char *)hash_get(stanza->attributes, key)); -+ tmp = _escape_xml(stanza->ctx, -+ (char *)hash_get(stanza->attributes, key)); -+ if (tmp == NULL) return XMPP_EMEM; -+ ret = xmpp_snprintf(ptr, left, " %s=\"%s\"", key, tmp); -+ xmpp_free(stanza->ctx, tmp); - if (ret < 0) return XMPP_EMEM; - _render_update(&written, buflen, ret, &left, &ptr); - } diff --git a/dev-libs/libstrophe/files/libstrophe-xmpp-conn-disable-tls.patch b/dev-libs/libstrophe/files/libstrophe-xmpp-conn-disable-tls.patch deleted file mode 100644 index 56a801f..0000000 --- a/dev-libs/libstrophe/files/libstrophe-xmpp-conn-disable-tls.patch +++ /dev/null @@ -1,84 +0,0 @@ -commit 9615a55856ce6f1d0aabb4fb6b7f9a41c27a5391 -Author: James Booth -Date: Sun May 20 01:50:32 2012 +0100 - - Added option to disable TLS - - The connection object includes a tls_support flag, which can - be disabled with xmpp_conn_disable_tls(). - -diff --git a/src/auth.c b/src/auth.c -index d0c33cb..3bbdfec 100644 ---- a/src/auth.c -+++ b/src/auth.c -@@ -209,9 +209,13 @@ static int _handle_features(xmpp_conn_t * const conn, - - /* check for TLS */ - if (!conn->secured) { -- child = xmpp_stanza_get_child_by_name(stanza, "starttls"); -- if (child && (strcmp(xmpp_stanza_get_ns(child), XMPP_NS_TLS) == 0)) -- conn->tls_support = 1; -+ if (!conn->tls_disabled) { -+ child = xmpp_stanza_get_child_by_name(stanza, "starttls"); -+ if (child && (strcmp(xmpp_stanza_get_ns(child), XMPP_NS_TLS) == 0)) -+ conn->tls_support = 1; -+ } else { -+ conn->tls_disabled = 0; -+ } - } - - /* check for SASL */ -diff --git a/src/common.h b/src/common.h -index cafcbd4..9434e6f 100644 ---- a/src/common.h -+++ b/src/common.h -@@ -163,6 +163,7 @@ struct _xmpp_conn_t { - tls_t *tls; - - int tls_support; -+ int tls_disabled; - int tls_failed; /* set when tls fails, so we don't try again */ - int sasl_support; /* if true, field is a bitfield of supported - mechanisms */ -diff --git a/src/conn.c b/src/conn.c -index 0a4e61c..e53a7f9 100644 ---- a/src/conn.c -+++ b/src/conn.c -@@ -109,6 +109,7 @@ xmpp_conn_t *xmpp_conn_new(xmpp_ctx_t * const ctx) - conn->bound_jid = NULL; - - conn->tls_support = 0; -+ conn->tls_disabled = 0; - conn->tls_failed = 0; - conn->sasl_support = 0; - conn->secured = 0; -@@ -666,6 +667,17 @@ void conn_open_stream(xmpp_conn_t * const conn) - XMPP_NS_STREAMS); - } - -+/** Disable TLS for this connection, called by users of the library. -+ * Occasionally a server will be misconfigured to send the starttls -+ * feature, but wil not support the handshake. -+ * -+ * @param conn a Strophe connection object -+ */ -+void xmpp_conn_disable_tls(xmpp_conn_t * const conn) -+{ -+ conn->tls_disabled = 1; -+} -+ - static void _log_open_tag(xmpp_conn_t *conn, char **attrs) - { - char buf[4096]; -diff --git a/strophe.h b/strophe.h -index 347ff7d..e3a2f4d 100644 ---- a/strophe.h -+++ b/strophe.h -@@ -217,6 +217,7 @@ void xmpp_conn_set_jid(xmpp_conn_t * const conn, const char * const jid); - const char *xmpp_conn_get_pass(const xmpp_conn_t * const conn); - void xmpp_conn_set_pass(xmpp_conn_t * const conn, const char * const pass); - xmpp_ctx_t* xmpp_conn_get_context(xmpp_conn_t * const conn); -+void xmpp_conn_disable_tls(xmpp_conn_t * const conn); - - int xmpp_connect_client(xmpp_conn_t * const conn, - const char * const altdomain, -- cgit v1.2.1