Update of /cvsroot/gaim/gaim/src/protocols/jabber
In directory usw-pr-cvs1:/tmp/cvs-serv19503/src/protocols/jabber
Modified Files:
jabber.c
Log Message:
Added code to detect invalid JIDs and prevent Gaim from crashing on them.
Removed "safety check" call in jabber_handlebuddy() to apparently broken
xmlnode_get_datasz() function.
Index: jabber.c
===================================================================
RCS file: /cvsroot/gaim/gaim/src/protocols/jabber/jabber.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- jabber.c 8 May 2002 00:50:22 -0000 1.48
+++ jabber.c 9 May 2002 13:53:12 -0000 1.49
@@ -210,7 +210,10 @@
}
gjc->p = p;
- gjc->user = jid_new(p, user);
+ if((gjc->user = jid_new(p, user)) == NULL) {
+ pool_free(p); /* no need for this anymore! */
+ return (NULL);
+ }
gjc->pass = pstrdup(p, pass);
gjc->state = JCONN_STATE_OFF;
@@ -684,6 +687,23 @@
}
/*
+ * Remove a buddy from the (gaim) buddylist (if he's on it)
+ */
+static void jabber_remove_gaim_buddy(struct gaim_connection *gc, char *buddyname)
+{
+ struct buddy *b;
+
+ if ((b = find_buddy(gc, buddyname)) != NULL) {
+ struct group *group;
+
+ group = find_group_by_buddy(gc, buddyname);
+ debug_printf("removing buddy [1]: %s, from group: %s\n", buddyname, group->name);
+ remove_buddy(gc, group, b);
+ do_export(gc);
+ }
+}
+
+/*
* keep track of away msg same as yahoo plugin
*/
static void jabber_track_away(gjconn gjc, jpacket p, char *name, char *type)
@@ -1224,7 +1244,7 @@
buddyname = g_strdup_printf("%s@%s", who->user, who->server);
- if((g = xmlnode_get_tag(x, "group")) != NULL && xmlnode_get_datasz(g) > 0) {
+ if((g = xmlnode_get_tag(x, "group")) != NULL) {
groupname = xmlnode_get_data(g);
}
@@ -1266,15 +1286,7 @@
}
}
} else if (BUD_USUB_TO_PEND(sub, ask) || BUD_USUBD_TO(sub, ask) || !strcasecmp(sub, "remove")) {
- if ((b = find_buddy(GJ_GC(gjc), buddyname)) != NULL) {
- struct group *group;
-
- group = find_group_by_buddy(GJ_GC(gjc), buddyname);
- debug_printf("removing buddy [1]: %s, from group: %s\n",
- buddyname, group->name);
- remove_buddy(GJ_GC(gjc), group, b);
- do_export(GJ_GC(gjc));
- }
+ jabber_remove_gaim_buddy(GJ_GC(gjc), buddyname);
}
g_free(buddyname);
@@ -1623,9 +1635,11 @@
{
struct jabber_data *jd = data;
- gjab_delete(jd->gjc);
- g_free(jd->gjc->sid);
- jd->gjc = NULL;
+ if(jd->gjc != NULL) {
+ gjab_delete(jd->gjc);
+ g_free(jd->gjc->sid);
+ jd->gjc = NULL;
+ }
g_free(jd);
return FALSE;
@@ -1653,7 +1667,7 @@
}
/* Free-up the pending queries memories and the list */
- if(jd->gjc->queries != NULL) {
+ if(jd->gjc != NULL && jd->gjc->queries != NULL) {
g_hash_table_foreach_remove(jd->gjc->queries, jabber_destroy_hash, NULL);
g_hash_table_destroy(jd->gjc->queries);
jd->gjc->queries = NULL;
@@ -1664,7 +1678,8 @@
if(jd) {
g_timeout_add(50, jabber_free, jd);
- xmlnode_free(jd->gjc->current);
+ if(jd->gjc != NULL)
+ xmlnode_free(jd->gjc->current);
}
gc->proto_data = NULL;
}
@@ -1787,7 +1802,15 @@
if (!strchr(name, '@'))
realwho = g_strdup_printf("%s@%s", name, gjc->user->server);
else {
- jid who = jid_new(gjc->p, name);
+ jid who;
+
+ if((who = jid_new(gjc->p, name)) == NULL) {
+ char *msg = g_strdup_printf("%s: \"%s\"", _("Invalid Jabber I.D."), name);
+ do_error_dialog(msg, _("Jabber Error"));
+ g_free(msg);
+ jabber_remove_gaim_buddy(gc, name);
+ return;
+ }
if (who->user == NULL) {
/* FIXME: transport */
return;
@@ -1927,7 +1950,12 @@
data->next->next->data);
debug_printf("%s\n", realwho);
- Jid = jid_new(gjc->p, realwho);
+ if((Jid = jid_new(gjc->p, realwho)) == NULL) {
+ char *msg = g_strdup_printf("%s: \"%s\"", _("Invalid Jabber I.D."), realwho);
+ do_error_dialog(msg, _("Jabber Error"));
+ g_free(msg);
+ return;
+ }
if((jc = find_any_chat(gc, Jid)) != NULL) {
free(Jid); /* don't need it, after all */
|