diff -Nru libstrophe-0.9.1+git20170912.6e6093e/ChangeLog libstrophe-0.9.2/ChangeLog --- libstrophe-0.9.1+git20170912.6e6093e/ChangeLog 2017-09-12 14:45:11.000000000 +0000 +++ libstrophe-0.9.2/ChangeLog 2018-02-23 12:19:15.000000000 +0000 @@ -8,6 +8,9 @@ userdata - System handlers are deleted on xmpp_conn_t reconnection. Old system handlers could cause problems + - Default timeout for xmpp_run() is increased from 1 millisecond to 1 + second in order to reduce CPU consumption + - Reduced memory usage in expat module - New functions: - xmpp_ctx_set_timeout() - xmpp_sha1_digest() diff -Nru libstrophe-0.9.1+git20170912.6e6093e/configure.ac libstrophe-0.9.2/configure.ac --- libstrophe-0.9.1+git20170912.6e6093e/configure.ac 2017-09-12 14:45:11.000000000 +0000 +++ libstrophe-0.9.2/configure.ac 2018-02-23 12:19:15.000000000 +0000 @@ -1,4 +1,4 @@ -AC_INIT([libstrophe], [0.9.1], [jack@metajack.im]) +AC_INIT([libstrophe], [0.9.2], [jack@metajack.im]) AC_CONFIG_MACRO_DIR([m4]) AM_INIT_AUTOMAKE([foreign]) LT_INIT([dlopen]) diff -Nru libstrophe-0.9.1+git20170912.6e6093e/debian/changelog libstrophe-0.9.2/debian/changelog --- libstrophe-0.9.1+git20170912.6e6093e/debian/changelog 2018-02-18 22:34:45.000000000 +0000 +++ libstrophe-0.9.2/debian/changelog 2018-02-24 14:13:43.000000000 +0000 @@ -1,3 +1,9 @@ +libstrophe (0.9.2-1) unstable; urgency=medium + + * New upstream version 0.9.2 + + -- Tomasz Buchert Sat, 24 Feb 2018 15:13:43 +0100 + libstrophe (0.9.1+git20170912.6e6093e-2) unstable; urgency=medium * Update links to salsa diff -Nru libstrophe-0.9.1+git20170912.6e6093e/debian/rules libstrophe-0.9.2/debian/rules --- libstrophe-0.9.1+git20170912.6e6093e/debian/rules 2018-02-18 22:34:45.000000000 +0000 +++ libstrophe-0.9.2/debian/rules 2018-02-24 14:13:43.000000000 +0000 @@ -4,8 +4,7 @@ export DEB_BUILD_MAINT_OPTIONS=hardening=+bindnow %: - dh $@ --parallel --with autoreconf + dh $@ --with autoreconf override_dh_autoreconf: dh_autoreconf ./bootstrap.sh - diff -Nru libstrophe-0.9.1+git20170912.6e6093e/Makefile.am libstrophe-0.9.2/Makefile.am --- libstrophe-0.9.1+git20170912.6e6093e/Makefile.am 2017-09-12 14:45:11.000000000 +0000 +++ libstrophe-0.9.2/Makefile.am 2018-02-23 12:19:15.000000000 +0000 @@ -11,7 +11,7 @@ RESOLV_LIBS = @RESOLV_LIBS@ -STROPHE_FLAGS = -I$(top_srcdir) -Wall -Wextra -Werror -Wno-unused-parameter +STROPHE_FLAGS = -I$(top_srcdir) -Wall -Wextra -Wno-unused-parameter STROPHE_LIBS = libstrophe.la ## Main build targets diff -Nru libstrophe-0.9.1+git20170912.6e6093e/src/crypto.c libstrophe-0.9.2/src/crypto.c --- libstrophe-0.9.1+git20170912.6e6093e/src/crypto.c 2017-09-12 14:45:11.000000000 +0000 +++ libstrophe-0.9.2/src/crypto.c 2018-02-23 12:19:15.000000000 +0000 @@ -61,7 +61,7 @@ return s; } -/** Compute SHA1 message digest +/** Compute SHA1 message digest. * Returns an allocated string which represents SHA1 message digest in * hexadecimal notation. The string must be freed with xmpp_free(). * @@ -81,7 +81,7 @@ return digest_to_string_alloc(ctx, digest); } -/** Compute SHA1 message digest +/** Compute SHA1 message digest. * Stores digest in user's buffer which must be at least XMPP_SHA1_DIGEST_SIZE * bytes long. * @@ -97,7 +97,7 @@ crypto_SHA1((const uint8_t *)data, len, digest); } -/** Create new SHA1 object +/** Create new SHA1 object. * SHA1 object is used to compute SHA1 digest of a buffer that is split * in multiple chunks or provided in stream mode. A single buffer can be * processed by short functions xmpp_sha1() and xmpp_sha1_digest(). @@ -111,7 +111,7 @@ * xmpp_sha1_free(sha1); * @endcode * - * @param ctx a Strophe context onject + * @param ctx a Strophe context object * * @return new SHA1 object * @@ -130,7 +130,7 @@ return sha1; } -/** Destroy SHA1 object +/** Destroy SHA1 object. * * @param sha1 a SHA1 object * @@ -141,7 +141,7 @@ xmpp_free(sha1->xmpp_ctx, sha1); } -/** Update SHA1 context with the next portion of data +/** Update SHA1 context with the next portion of data. * Can be called repeatedly. * * @param sha1 a SHA1 object @@ -155,7 +155,7 @@ crypto_SHA1_Update(&sha1->ctx, data, len); } -/** Finish SHA1 computation +/** Finish SHA1 computation. * Don't call xmpp_sha1_update() after this function. Retrieve resulting * message digest with xmpp_sha1_to_string() or xmpp_sha1_to_digest(). * @@ -168,7 +168,7 @@ crypto_SHA1_Final(&sha1->ctx, sha1->digest); } -/** Return message digest rendered as a string +/** Return message digest rendered as a string. * Stores the string to a user's buffer and returns the buffer. Call this * function after xmpp_sha1_final(). * @@ -185,7 +185,7 @@ return digest_to_string(sha1->digest, s, slen); } -/** Return message digest rendered as a string +/** Return message digest rendered as a string. * Returns an allocated string. Free the string using the Strophe context * which is passed to xmpp_sha1_new(). Call this function after * xmpp_sha1_final(). @@ -201,7 +201,7 @@ return digest_to_string_alloc(sha1->xmpp_ctx, sha1->digest); } -/** Stores message digest to a user's buffer +/** Stores message digest to a user's buffer. * * @param sha1 a SHA1 object * @param digest output buffer of XMPP_SHA1_DIGEST_SIZE bytes @@ -419,7 +419,7 @@ *outlen = 0; } -/** Base64 encoding routine +/** Base64 encoding routine. * Returns an allocated string which must be freed with xmpp_free(). * * @param ctx a Strophe context @@ -435,7 +435,7 @@ return base64_encode(ctx, data, len); } -/** Base64 decoding routine +/** Base64 decoding routine. * Returns an allocated string which must be freed with xmpp_free(). User * calls this function when the result must be a string. When decoded buffer * contains '\0' NULL is returned. @@ -471,7 +471,7 @@ return (char *)buf; } -/** Base64 decoding routine +/** Base64 decoding routine. * Returns an allocated buffer which must be freed with xmpp_free(). * * @param ctx a Strophe context diff -Nru libstrophe-0.9.1+git20170912.6e6093e/src/parser_libxml2.c libstrophe-0.9.2/src/parser_libxml2.c --- libstrophe-0.9.1+git20170912.6e6093e/src/parser_libxml2.c 2017-09-12 14:45:11.000000000 +0000 +++ libstrophe-0.9.2/src/parser_libxml2.c 2018-02-23 12:19:15.000000000 +0000 @@ -249,6 +249,8 @@ { if (parser->xmlctx) xmlFreeParserCtxt(parser->xmlctx); + if (parser->stanza) + xmpp_stanza_release(parser->stanza); xmpp_free(parser->ctx, parser); } @@ -257,18 +259,16 @@ { if (parser->xmlctx) xmlFreeParserCtxt(parser->xmlctx); - if (parser->stanza) xmpp_stanza_release(parser->stanza); + parser->stanza = NULL; + parser->depth = 0; + parser->xmlctx = xmlCreatePushParserCtxt(&parser->handlers, parser, NULL, 0, NULL); - if (!parser->xmlctx) return 0; - - parser->depth = 0; - parser->stanza = NULL; - return 1; + return parser->xmlctx ? 1 : 0; } /* feed a chunk of data to the parser */ diff -Nru libstrophe-0.9.1+git20170912.6e6093e/src/resolver.c libstrophe-0.9.2/src/resolver.c --- libstrophe-0.9.1+git20170912.6e6093e/src/resolver.c 2017-09-12 14:45:11.000000000 +0000 +++ libstrophe-0.9.2/src/resolver.c 2018-02-23 12:19:15.000000000 +0000 @@ -550,7 +550,7 @@ char buffer[65535]; len = 65535; - fi = buffer; + fi = (FIXED_INFO *)buffer; if ((error = pGetNetworkParams(fi, &len)) == ERROR_SUCCESS) { diff -Nru libstrophe-0.9.1+git20170912.6e6093e/src/sasl.c libstrophe-0.9.2/src/sasl.c --- libstrophe-0.9.1+git20170912.6e6093e/src/sasl.c 2017-09-12 14:45:11.000000000 +0000 +++ libstrophe-0.9.2/src/sasl.c 2018-02-23 12:19:15.000000000 +0000 @@ -264,7 +264,8 @@ xmpp_rand_nonce(ctx->rand, cnonce, sizeof(cnonce)); hash_add(table, "cnonce", xmpp_strdup(ctx, cnonce)); hash_add(table, "nc", xmpp_strdup(ctx, "00000001")); - hash_add(table, "qop", xmpp_strdup(ctx, "auth")); + if (hash_get(table, "qop") == NULL) + hash_add(table, "qop", xmpp_strdup(ctx, "auth")); value = xmpp_alloc(ctx, 5 + strlen(domain) + 1); memcpy(value, "xmpp/", 5); memcpy(value+5, domain, strlen(domain)); diff -Nru libstrophe-0.9.1+git20170912.6e6093e/src/stanza.c libstrophe-0.9.2/src/stanza.c --- libstrophe-0.9.1+git20170912.6e6093e/src/stanza.c 2017-09-12 14:45:11.000000000 +0000 +++ libstrophe-0.9.2/src/stanza.c 2018-02-23 12:19:15.000000000 +0000 @@ -1220,7 +1220,7 @@ } /** Create an stanza object with given type and error text. - * iError text are optional and may be NULL. + * The error text is optional and may be NULL. * * @param ctx a Strophe context object * @param type enum of xmpp_error_type_t @@ -1228,9 +1228,12 @@ * * @return a new Strophe stanza object * + * @todo Handle errors in this function + * * @ingroup Stanza */ -xmpp_stanza_t *xmpp_error_new(xmpp_ctx_t *ctx, xmpp_error_type_t const type, char * const text) +xmpp_stanza_t *xmpp_error_new(xmpp_ctx_t *ctx, xmpp_error_type_t const type, + const char * const text) { xmpp_stanza_t *error = _stanza_new_with_attrs(ctx, "stream:error", NULL, NULL, NULL); xmpp_stanza_t *error_type = xmpp_stanza_new(ctx); @@ -1319,10 +1322,11 @@ if (text) { xmpp_stanza_t *error_text = xmpp_stanza_new(ctx); + xmpp_stanza_t *content = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(error_text, "text"); xmpp_stanza_set_ns(error_text, XMPP_NS_STREAMS_IETF); - xmpp_stanza_t *content = xmpp_stanza_new(ctx); xmpp_stanza_set_text(content, text); xmpp_stanza_add_child(error_text, content); xmpp_stanza_release(content); diff -Nru libstrophe-0.9.1+git20170912.6e6093e/src/tls_openssl.c libstrophe-0.9.2/src/tls_openssl.c --- libstrophe-0.9.1+git20170912.6e6093e/src/tls_openssl.c 2017-09-12 14:45:11.000000000 +0000 +++ libstrophe-0.9.2/src/tls_openssl.c 2018-02-23 12:19:15.000000000 +0000 @@ -209,6 +209,14 @@ } _tls_sock_wait(tls, error); } + if (error == SSL_ERROR_SYSCALL && errno == 0) { + /* + * Handle special case when peer closes connection instead of + * proper shutdown. + */ + error = 0; + ret = 1; + } _tls_set_error(tls, error); return ret <= 0 ? 0 : 1; @@ -260,6 +268,8 @@ int nfds; int ret; + if (error == SSL_ERROR_NONE) return; + FD_ZERO(&rfds); FD_ZERO(&wfds); if (error == SSL_ERROR_WANT_READ) @@ -278,7 +288,7 @@ static void _tls_set_error(tls_t *tls, int error) { if (error != 0 && !tls_is_recoverable(error)) { - xmpp_debug(tls->ctx, "tls", "errno=%d", errno); + xmpp_debug(tls->ctx, "tls", "error=%d errno=%d", error, errno); _tls_log_error(tls->ctx); } tls->lasterror = error; diff -Nru libstrophe-0.9.1+git20170912.6e6093e/strophe.h libstrophe-0.9.2/strophe.h --- libstrophe-0.9.1+git20170912.6e6093e/strophe.h 2017-09-12 14:45:11.000000000 +0000 +++ libstrophe-0.9.2/strophe.h 2018-02-23 12:19:15.000000000 +0000 @@ -382,7 +382,8 @@ xmpp_stanza_t *xmpp_iq_new(xmpp_ctx_t *ctx, const char * const type, const char * const id); xmpp_stanza_t *xmpp_presence_new(xmpp_ctx_t *ctx); -xmpp_stanza_t *xmpp_error_new(xmpp_ctx_t *ctx, xmpp_error_type_t const type, char * const text); +xmpp_stanza_t *xmpp_error_new(xmpp_ctx_t *ctx, xmpp_error_type_t const type, + const char * const text); /* jid */ diff -Nru libstrophe-0.9.1+git20170912.6e6093e/tests/test_string.c libstrophe-0.9.2/tests/test_string.c --- libstrophe-0.9.1+git20170912.6e6093e/tests/test_string.c 2017-09-12 14:45:11.000000000 +0000 +++ libstrophe-0.9.2/tests/test_string.c 2018-02-23 12:19:15.000000000 +0000 @@ -20,6 +20,16 @@ #include "test.h" /* ARRAY_SIZE */ +/* strtok_s() has appeared in visual studio 2005. + Use own implementation for older versions. */ +#ifdef _MSC_VER +# if (_MSC_VER >= 1400) +# define strtok_r strtok_s +# else +# define strtok_r xmpp_strtok_r +# endif +#endif /* _MSC_VER */ + static int test_strtok_r(void) { const char *test = "-abc-=-def--";