summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2011-02-07 14:21:13 +0100
committerWill Thompson <will.thompson@collabora.co.uk>2011-03-01 15:33:27 +0000
commit55b4db92591ecc72bd5393d2ae66d84fbc8e9063 (patch)
treedaedc7f990609cc3dcf73521b1cffc0c7b7335ba /tests
parent33195c80d34dce29a466dabfa3bb494f7b3554ae (diff)
XmppReader: don't crash on <stream:stream lang='foo'...>
Previously, if the stream header contained a 'lang' attribute with no namespace prefix, we'd pass NULL to strcmp, and crash.
Diffstat (limited to 'tests')
-rw-r--r--tests/wocky-xmpp-reader-test.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/wocky-xmpp-reader-test.c b/tests/wocky-xmpp-reader-test.c
index 62cdb64..daab721 100644
--- a/tests/wocky-xmpp-reader-test.c
+++ b/tests/wocky-xmpp-reader-test.c
@@ -22,6 +22,12 @@
"<stream:streamsss xmlns='jabber:client' " \
" xmlns:stream='http://etherx.jabber.org/streams'> "
+#define HEADER_WITH_UNQUALIFIED_LANG \
+"<?xml version='1.0' encoding='UTF-8'?> " \
+"<stream:stream xmlns='jabber:client' " \
+" xmlns:stream='http://etherx.jabber.org/streams' " \
+" lang='fi'> "
+
#define BROKEN_MESSAGE \
" <message to='juliet@example.com' from='romeo@example.net' xml:lang='en' " \
" id=\"0\"> " \
@@ -130,6 +136,24 @@ test_stream_open_error (void)
}
static void
+test_stream_open_unqualified_lang (void)
+{
+ WockyXmppReader *reader = wocky_xmpp_reader_new ();
+
+ g_assert (wocky_xmpp_reader_get_state (reader)
+ == WOCKY_XMPP_READER_STATE_INITIAL);
+
+ wocky_xmpp_reader_push (reader,
+ (guint8 *) HEADER_WITH_UNQUALIFIED_LANG,
+ strlen (HEADER_WITH_UNQUALIFIED_LANG));
+
+ g_assert (wocky_xmpp_reader_get_state (reader)
+ == WOCKY_XMPP_READER_STATE_OPENED);
+
+ g_object_unref (reader);
+}
+
+static void
test_parse_error (void)
{
WockyXmppReader *reader;
@@ -292,6 +316,8 @@ main (int argc,
g_test_add_func ("/xmpp-reader/stream-no-stanzas", test_stream_no_stanzas);
g_test_add_func ("/xmpp-reader/stream-open-error", test_stream_open_error);
+ g_test_add_func ("/xmpp-reader/stream-open-unqualified-lang",
+ test_stream_open_unqualified_lang);
g_test_add_func ("/xmpp-reader/parse-error", test_parse_error);
g_test_add_func ("/xmpp-reader/no-stream-hunks", test_no_stream_hunks);
g_test_add_func ("/xmpp-reader/no-stream-resetting", test_no_stream_reset);