# HG changeset patch # User Mikael Berthe # Date 1344075477 -7200 # Node ID 66455f258c64799e042b88ad23ab1994b2c0f898 # Parent cbae62eecb1d186d8f7d1c7c473dc391a6b7c9ee Check user-supplied JID, change memory allocation tracking logic diff -r cbae62eecb1d -r 66455f258c64 marking.c --- a/marking.c Sun Jul 22 15:37:10 2012 +0300 +++ b/marking.c Sat Aug 04 12:17:57 2012 +0200 @@ -70,18 +70,26 @@ if (args[0]) { cmd = args[0]; - if (args[1]) - jid = jidtodisp (args[1]); + if (args[1]) { + const char *j = args[1]; + if (check_jid_syntax(j)) { + scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, + "<%s> is not a valid Jabber ID.", j); + return; + } + jid = jidtodisp(j); + jfree = TRUE; + } } else cmd = "set"; - + if (!strcmp (cmd, "set")) { if (!g_slist_find_custom (marked_jids, jid ? jid : CURRENT_JID, (GCompareFunc) g_strcmp0)) { marked_jids = g_slist_append (marked_jids, jid ? jid : g_strdup (CURRENT_JID)); marked = 1; - } else - jfree = TRUE; + jfree = FALSE; + } } else if (!strcmp (cmd, "clear")) { @@ -93,8 +101,6 @@ marked = 0; } - jfree = TRUE; - } else if (!strcmp (cmd, "toggle")) { GSList *mel = g_slist_find_custom (marked_jids, jid ? jid : CURRENT_JID, (GCompareFunc) g_strcmp0); @@ -103,10 +109,10 @@ g_free (mel->data); marked_jids = g_slist_delete_link (marked_jids, mel); marked = 0; - jfree = TRUE; } else { marked_jids = g_slist_append (marked_jids, jid ? jid : g_strdup (CURRENT_JID)); marked = 1; + jfree = FALSE; } }