d8da993a73943390ccda275449eccf90cc10c248
When xmpp_vsnprintf() received count == 0 it still performs write to the buffer. This leads to a write outside allocated memory, when xmpp_stanza_to_text() parses a specific stanza. Because of error in _render_update() writing exactly buflen+1 with xmpp_snprintf() is counted as valid operation and next xmpp_snprintf will be performed to a buffer with zero length. This leads to wrong rendering of 1024-length stanzas and invalid write for specific larger stanzas: ==22436== Invalid write of size 1 ==22436== at 0x4E4B3A1: xmpp_vsnprintf (snprintf.c:709) ==22436== by 0x4E4B479: xmpp_snprintf (snprintf.c:722) ==22436== by 0x4E4C011: _render_stanza_recursive (stanza.c:328) ==22436== by 0x4E4C3B3: _render_stanza_recursive (stanza.c:384) ==22436== by 0x4E4C3B3: _render_stanza_recursive (stanza.c:384) ==22436== by 0x4E4C3B3: _render_stanza_recursive (stanza.c:384) ==22436== by 0x4E4C3B3: _render_stanza_recursive (stanza.c:384) ==22436== by 0x4E4C3B3: _render_stanza_recursive (stanza.c:384) ==22436== by 0x4E4C4E5: xmpp_stanza_to_text (stanza.c:435) ==22436== by 0x4E407A8: _handle_stream_stanza (conn.c:1157) ==22436== by 0x4E4EF2B: _end_element (parser_expat.c:157) ==22436== by 0x571005A: doContent (in /usr/lib64/libexpat.so.1.6.2) ==22436== Address 0x63b95b0 is 0 bytes after a block of size 1,024 alloc'd ==22436== at 0x4C2BFE0: malloc (vg_replace_malloc.c:299) ==22436== by 0x4E41947: _malloc (ctx.c:116) ==22436== by 0x4E41A54: xmpp_alloc (ctx.c:204) ==22436== by 0x4E4C4A3: xmpp_stanza_to_text (stanza.c:428) ==22436== by 0x4E407A8: _handle_stream_stanza (conn.c:1157) ==22436== by 0x4E4EF2B: _end_element (parser_expat.c:157) ==22436== by 0x571005A: doContent (in /usr/lib64/libexpat.so.1.6.2) ==22436== by 0x57109FB: contentProcessor (in ... ==22436== by 0x5712A9F: XML_ParseBuffer (in ... ==22436== by 0x4E4F1E7: parser_feed (parser_expat.c:247) ==22436== by 0x4E42BBC: xmpp_run_once (event.c:284) ==22436== by 0x4E42D62: xmpp_run (event.c:336) Fix xmpp_vsnprintf() and _render_update() behaviour.
libstrophe [](https://travis-ci.org/strophe/libstrophe)
==========
libstrophe is a lightweight XMPP client library written in C. It has
minimal dependencies and is configurable for various environments. It
runs well on Linux, Unix and Windows based platforms.
Its goals are:
- usable quickly
- well documented
- reliable
Build Instructions
------------------
If you are building from a source control checkout, run:
./bootstrap.sh
to generate the `configure` script.
From the top-level directory, run the following commands:
./configure
make
The public API is defined in `strophe.h` which is in the
top-level directory.
The `examples` directory contains some examples of how to
use the library; these may be helpful in addition to the
API documentation
To install on your system, as root (or using sudo):
make install
Note, the default install path is `/usr/local/`, to specify
another path use the `--prefix` option during configure, e.g.:
./configure --prefix=/usr
### Android
Run script `build-android.sh` and follow the instructions. You will
need expat sources and android-ndk.
Requirements
------------
libstrophe requires:
- expat or libxml2 - expat is the default; use --with-libxml2 to
switch
- openssl on UNIX systems
To build libstrophe using autotools you will need autoconf, automake,
libtool and pkg-config.
In addition, if you wish to run the unit tests, you will need the
check package.
Installation
------------
libstrophe package has been added to popular Linux distributions,
BSD systems and OSX package managers.
Documentation
-------------
API documentation is inline with the code and conforms to Doxygen
standards. You can generate an HTML version of the API documentation
by running:
doxygen
Then open `docs/html/index.html`.
Description
Languages
C
95.1%
M4
2.9%
Makefile
1.7%
Shell
0.3%