annotate libpurple/tests/test_oscar_util.c @ 32797:aacfb71133cc

Fix a possible MSN remote crash Incoming messages with certain characters or character encodings can cause clients to crash. The fix is for the contents of all incoming plaintext messages are converted to UTF-8 and validated before used. This was reported to us by Fabian Yamaguchi and this patch was written by Elliott Sales de Andrade (maybe with small, insignificant changes by me)
author Mark Doliner <mark@kingant.net>
date Mon, 07 May 2012 03:18:08 +0000
parents f1874b08b3f9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31204
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1 #include <string.h>
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
2
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
3 #include "tests.h"
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
4 #include "../protocols/oscar/oscar.h"
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
5
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
6 START_TEST(test_oscar_util_name_compare)
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
7 {
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
8 int i;
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
9 const char *good[] = {
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
10 "test",
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
11 "TEST",
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
12 "Test",
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
13 "teSt",
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
14 " TesT",
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
15 "test ",
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
16 " T E s T "
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
17 };
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
18 const char *bad[] = {
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
19 "toast",
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
20 "test@example.com",
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
21 "test@aim.com"
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
22 };
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
23
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
24 for (i = 0; i < G_N_ELEMENTS(good); i++) {
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
25 ck_assert_int_eq(0, oscar_util_name_compare("test", good[i]));
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
26 ck_assert_int_eq(0, oscar_util_name_compare(good[i], "test"));
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
27 }
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
28 for (i = 0; i < G_N_ELEMENTS(bad); i++) {
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
29 ck_assert_int_ne(0, oscar_util_name_compare("test", bad[i]));
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
30 ck_assert_int_ne(0, oscar_util_name_compare(bad[i], "test"));
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
31 }
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
32 }
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
33 END_TEST
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
34
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
35 Suite *oscar_util_suite(void)
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
36 {
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
37 Suite *s;
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
38 TCase *tc;
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
39
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
40 s = suite_create("OSCAR Utility Functions");
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
41
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
42 tc = tcase_create("Convert IM from network format to HTML");
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
43 tcase_add_test(tc, test_oscar_util_name_compare);
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
44 suite_add_tcase(s, tc);
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
45
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
46 return s;
f1874b08b3f9 Add unit tests for oscar_util_name_compare. I suspected that this
Mark Doliner <mark@kingant.net>
parents:
diff changeset
47 }