Mercurial > pidgin.yaz
annotate libpurple/protocols/msnp9/group.c @ 28875:8464e695c62b
Fixes a bad MSN bug where passwords with multi-byte utf8 characters near
the 16 byte mark would cause a segmentation fault due to chopping the
multi-byte character and turning the string into invalidate utf8.
Thanks to Shaun Lindsay at Meebo for tracking this down and fixing it.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 04 Nov 2009 18:41:21 +0000 |
parents | a07cfce78345 |
children |
rev | line source |
---|---|
21312
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
1 /** |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
2 * @file group.c Group functions |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
3 * |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
4 * purple |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
5 * |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
6 * Purple is the legal property of its developers, whose names are too numerous |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
8 * source distribution. |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
9 * |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
10 * This program is free software; you can redistribute it and/or modify |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
13 * (at your option) any later version. |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
14 * |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
15 * This program is distributed in the hope that it will be useful, |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
18 * GNU General Public License for more details. |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
19 * |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
20 * You should have received a copy of the GNU General Public License |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
21 * along with this program; if not, write to the Free Software |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
23 */ |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
24 #include "msn.h" |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
25 #include "group.h" |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
26 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
27 MsnGroup * |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
28 msn_group_new(MsnUserList *userlist, int id, const char *name) |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
29 { |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
30 MsnGroup *group; |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
31 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
32 g_return_val_if_fail(id >= 0, NULL); |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
33 g_return_val_if_fail(name != NULL, NULL); |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
34 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
35 group = g_new0(MsnGroup, 1); |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
36 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
37 msn_userlist_add_group(userlist, group); |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
38 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
39 group->id = id; |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
40 group->name = g_strdup(name); |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
41 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
42 return group; |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
43 } |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
44 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
45 void |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
46 msn_group_destroy(MsnGroup *group) |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
47 { |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
48 g_return_if_fail(group != NULL); |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
49 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
50 g_free(group->name); |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
51 g_free(group); |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
52 } |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
53 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
54 void |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
55 msn_group_set_id(MsnGroup *group, int id) |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
56 { |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
57 g_return_if_fail(group != NULL); |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
58 g_return_if_fail(id >= 0); |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
59 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
60 group->id = id; |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
61 } |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
62 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
63 void |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
64 msn_group_set_name(MsnGroup *group, const char *name) |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
65 { |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
66 g_return_if_fail(group != NULL); |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
67 g_return_if_fail(name != NULL); |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
68 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
69 if (group->name != NULL) |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
70 g_free(group->name); |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
71 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
72 group->name = g_strdup(name); |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
73 } |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
74 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
75 int |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
76 msn_group_get_id(const MsnGroup *group) |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
77 { |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
78 g_return_val_if_fail(group != NULL, -1); |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
79 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
80 return group->id; |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
81 } |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
82 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
83 const char * |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
84 msn_group_get_name(const MsnGroup *group) |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
85 { |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
86 g_return_val_if_fail(group != NULL, NULL); |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
87 |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
88 return group->name; |
a07cfce78345
Add MSNP9 back as an alternative alongside the existing MSN prpl. Cowardly
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff
changeset
|
89 } |