508 Commits

Author SHA1 Message Date
Dmitry Podgorny
9dfe01bf83 WIP examples: PLAIN auth mechanism over raw connection 2017-07-15 21:38:46 +03:00
Dmitry Podgorny
b1b827cde6 conn: clear features support on connection reset
Features may be changed when client reconnects.
2017-07-15 21:32:55 +03:00
Dmitry Podgorny
e73b577e0b auth: use xmpp_iq_new() for iq stanzas 2017-07-15 20:35:16 +03:00
Dmitry Podgorny
8d2d59e914 tls/openssl: add OpenSSL-1.1.0 support (#109)
OpenSSL-1.1.0 marks cleanup functions as deprecated and changes
initialization function. It implements implicit de-initialization.

Reported by @zygmund2000.
2017-07-12 02:07:14 +03:00
Dmitry Podgorny
212f3ea760 snprintf: fix compilation with GCC 7 (#108)
GCC 7 enables -Wimplicit-fallthrough=3 with -Wextra. Add comments to
suppress these warning explicitly.

Reported by @akoww
2017-07-11 03:21:31 +03:00
Dmitry Podgorny
4aa7ea7e5b parser/expat: update #47
@curse666 suggested solution for #46 which reduces memory usage in expat
module. Current patch fixes few issues:
  - Inner text is lost for depth 1 stanzas
  - Incorrect handling of mixed xml <x>text<y/></x>
  - Reduced number of realloc() calls
2017-07-06 22:32:20 +03:00
curse666
5f9c0399c3 Update parser_expat.c
solution for #46.
2017-07-06 19:25:20 +03:00
Dmitry Podgorny
b83347b464 examples: use xmpp_iq_new() 2017-07-06 15:47:19 +03:00
Dmitry Podgorny
d8a86a54d5 event: set socket to wfds when sending queue is not empty
Don't sleep in select(2) when system is ready to send data.
2017-07-05 20:36:34 +03:00
Dmitry Podgorny
49289a9c05 event: reduce copy-paste 2017-07-05 20:34:38 +03:00
Dmitry Podgorny
456083d878 stanza: fix memory leaks
Free attribute "to" before replacing it in xmpp_stanza_reply().
Free value on insertion error in xmpp_stanza_set_attribute().
Don't copy attributes manually. Use xmpp_stanza_set_attribute() instead.
2017-07-05 20:20:45 +03:00
Dmitry Podgorny
15e7032f0d examples/bot: handle quit message 2017-07-05 19:40:25 +03:00
Dmitry Podgorny
cd2cf6eb23 ctx: set default event loop timeout to 1 second
Default timeout was 1 millisecond and it consumed CPU by running the
loop in xmpp_run(). The CPU usage was unacceptable and thus xmpp_run()
was not used by users. Also user can set the timeout by
xmpp_ctx_set_timeout() now.

Event loop already handles the situation when there is a timed handler
which needs to be run before the timeout is reached. Also system awakes
event loop when data arrives to socket.

The only drawback is when timed handler sends data it will be actually
sent after select(2) returns. But this situation can be handled easily by
adding socket to wfds when xmpp_conn_t contains data in sending queue.
2017-07-05 15:47:13 +03:00
Dmitry Podgorny
666995531a ChangeLog: mention recent changes
- Certificate verification is enabled for all openssl versions by
   default
 - xmpp_ctx_set_timeout()
 - Move xmpp_ctx_set_timeout() to event loop section in strophe.h
2017-07-04 19:22:26 +03:00
Dmitry Podgorny
9269d6b0d5 conn: add flag XMPP_CONN_FLAG_TRUST_TLS
TLS modules accept invalid server's certificates when the flag is set.
2017-07-04 17:20:33 +03:00
Dmitry Podgorny
c319ee6583 handler: fix memory leak and use-after-free errors
The errors are related to newly added handler_system_delete_all().
2017-07-01 16:24:30 +03:00
Dmitry Podgorny
cc53012cfa tls/openssl: enable cert verification for openssl older then 1.0.2
TODO: add flag to trust certificate even if verification fails.
2017-07-01 15:51:49 +03:00
Dmitry Podgorny
cc297eff45 handler: shut compiler up
Fixes the next warning:
    src/handler.c:683:25: error: ‘key2’ may be used uninitialized in
    this function [-Werror=uninitialized]

In fact key2 initialised and used under the same condition.
2017-06-29 20:43:03 +03:00
Dmitry Podgorny
e151096834 handler: don't call time_stamp() twice in handler_fire_timed() 2017-06-29 20:22:55 +03:00
Dmitry Podgorny
82040403bf tests/hash: enable the test 2017-06-29 20:22:55 +03:00
Dmitry Podgorny
a845c7ec3d hash: avoid allocation when replace value in hash_add()
Memory allocation may fail. We don't need to allocate new entry when we
already have one.
2017-06-29 20:22:55 +03:00
Dmitry Podgorny
5ecb0c5d0c conn: clear system handlers on reconnect
xmpp_conn_t object can be reused with saving user's handlers.
However, saving system handlers can lead to a fail during connection
process. This is because old object may contain timed handlers for
missed features or other handlers that would handle incoming stanzas
incorrectly.
2017-06-29 20:22:55 +03:00
Dmitry Podgorny
da8dc2d3cb auth: don't delete stream:error handler
Instead, keep the same handler until connection is disconnected. Stream
is opened 3 times during usual workflow. Deleting/restoring the handler
every time brings more places for possible mistakes.
2017-06-29 20:13:16 +03:00
Dmitry Podgorny
182695d1ca resolver: fix type mismatch in windows part
Backported from NetXMS project.
2017-06-29 20:00:25 +03:00
Dmitry Podgorny
0d039f7192 parser/libxml2: fix missed {} for multi-line block 2017-06-29 19:33:26 +03:00
Dmitry Podgorny
ebe97e8f2a travis-ci: don't use custom CFLAGS
Makefile.am provides -Wall and -Werror now.
2017-06-29 19:00:54 +03:00
Dmitry Podgorny
9505cace5e ctx: don't check whether log level is less than XMPP_LEVEL_DEBUG
XMPP_LEVEL_DEBUG is always 0.
2017-06-29 18:49:54 +03:00
Dmitry Podgorny
8ef027c54a ctx: fix indentation in xmpp_ctx_set_timeout() 2017-06-29 18:49:54 +03:00
Dmitry Podgorny
0bdb5f1d5b examples/vcard: fix warn_unused_result related to fwrite() 2017-06-29 18:49:54 +03:00
Steffen Jaeckel
49e7572059 fix function-pointer storage
the C standard says that you're not allowed to cast a function pointer to
something else

 6.3.2.3 §8:

A pointer to a function of one type may be converted to a pointer
to a function of another type and back again
2017-06-29 16:58:11 +02:00
Steffen Jaeckel
c074a6166c enable some warnings & fix 'em 2017-06-29 16:58:11 +02:00
Steffen Jaeckel
4c504ee42b add xmpp_ctx_set_timeout() 2017-06-29 16:58:11 +02:00
Steffen Jaeckel
f226891520 fix openssl memory leaks 2017-06-29 16:54:41 +02:00
Dmitry Podgorny
43a68479ad ChangeLog: mention about disabled insecure SSL/TLS
See f47609c1f0
2017-06-26 01:09:24 +03:00
Dmitry Podgorny
1e422a70dd crypto: add public function xmpp_sha1_digest()
For example, XEP-0115 requires binary digest to be base64-encoded.
Add short function to simplify such a digest computation for a single
buffer. This function doesn't allocate memory. Therefore, it can't
fail and doesn't require strophe context (xmpp_ctx_t).
2017-06-26 00:56:03 +03:00
Dmitry Podgorny
2a474bd809 tls/schannel: fix memory leak
Assume InitializeSecurityContext() doesn't change pszTargetName.
Reported by @youzpp in metajack/libstrophe#35.
2017-06-25 22:12:16 +03:00
Dmitry Podgorny
704c157d24 hash: don't use signed types during index calculation
Reported by @ITikhonov in pasis/libcouplet#10
2017-06-25 21:59:27 +03:00
Dmitry Podgorny
d8528b597c parser/libxml2: shorten parser_feed() 2017-06-25 21:19:15 +03:00
Dmitry Podgorny
c149caa32a examples: add vcard example
New exmaple shows how to request vCard and handle result. See XEP-0054
for details.
PHOTO element is stored to an image file.
2017-06-23 22:09:28 +03:00
Dmitry Podgorny
fa63aac731 auth: delete error handler before re-opening stream 2017-06-23 21:51:44 +03:00
Dmitry Podgorny
ba40bf1040 handler: fix possible corruption of handler lists
User's handler may delete other handlers. If deleted handler is the next
or the previous to the running one it leads to a list corruption.
Don't cache previous/next items when we walk through a handler's list.
2017-06-23 21:47:10 +03:00
Alexander Krotov
2f9bcfe145 Test xmpp_jid_bare 2017-06-23 20:00:41 +03:00
Alexander Krotov
b957213fdc Simplify xmpp_jid_{bare,domain,resource} 2017-06-23 19:55:12 +03:00
Alexander Krotov
f51b01a5b3 Remove unused mutex wrappers 2017-06-23 17:58:42 +03:00
Dmitry Podgorny
d2efc85ce3 Makefile.am: refactoring
Put filenames to separated lines to simplify adding/removing new files.
Add missed files to EXTRA_DIST.
2017-06-23 17:00:26 +03:00
Dmitry Podgorny
940d76e9e2 rpm: update dependencies 2017-06-23 16:57:27 +03:00
Dmitry Podgorny
59eb8d67ed ChangeLog: mention significant changes since 0.9.1 2017-06-23 16:55:31 +03:00
Dmitry Podgorny
78592650e5 tls/schannel: reflect changes of the tls interface
tls_new() accepts xmpp_conn_t object now.
2017-06-23 15:37:09 +03:00
Alexander Krotov
92d006a41b Disable hostname verification for pre-1.0.2 OpenSSL 2017-06-23 13:45:24 +03:00
Alexander Krotov
0741820711 Verify certificate hostname when using OpenSSL (fixes #100) 2017-06-23 03:00:26 +03:00