pidgin: 1967b5be: Add an error handler for SLP messages in...
qulogic at pidgin.im
qulogic at pidgin.im
Wed May 26 21:00:55 EDT 2010
-----------------------------------------------------------------
Revision: 1967b5bed9066e10d1c7db900af07d91cf852181
Ancestor: fcd99a6bb8c6362d64f295a1b95a5b1130460b85
Author: qulogic at pidgin.im
Date: 2010-05-26T23:08:53
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/1967b5bed9066e10d1c7db900af07d91cf852181
Modified files:
libpurple/protocols/msn/slp.c
ChangeLog:
Add an error handler for SLP messages instead of bailing out immediately.
-------------- next part --------------
============================================================
--- libpurple/protocols/msn/slp.c 78c241c55efeb4f69c7c68cd89785be4b960baa2
+++ libpurple/protocols/msn/slp.c 2122be21fc5a3facb60cf70cc278ce5495d7ed67
@@ -928,6 +928,17 @@ got_ok(MsnSlpCall *slpcall,
}
}
+static void
+got_error(MsnSlpCall *slpcall,
+ const char *error, const char *type, const char *content)
+{
+ /* It's not valid. Kill this off. */
+ purple_debug_error("msn", "Received non-OK result: %s\n",
+ error ? error : "Unknown");
+
+ slpcall->wasted = TRUE;
+}
+
MsnSlpCall *
msn_slp_sip_recv(MsnSlpLink *slplink, const char *body)
{
@@ -1004,38 +1015,31 @@ msn_slp_sip_recv(MsnSlpLink *slplink, co
g_return_val_if_fail(slpcall != NULL, NULL);
+ content_type = get_token(body, "Content-Type: ", "\r\n");
+
+ content = get_token(body, "\r\n\r\n", NULL);
+
if (strncmp(status, "200 OK", 6))
{
- /* It's not valid. Kill this off. */
- char temp[32];
+ char *error = NULL;
const char *c;
/* Eww */
if ((c = strchr(status, '\r')) || (c = strchr(status, '\n')) ||
(c = strchr(status, '\0')))
{
- size_t offset = c - status;
- if (offset >= sizeof(temp))
- offset = sizeof(temp) - 1;
-
- strncpy(temp, status, offset);
- temp[offset] = '\0';
+ size_t len = c - status;
+ error = g_strndup(status, len);
}
- purple_debug_error("msn", "Received non-OK result: %s\n", temp);
+ got_error(slpcall, error, content_type, content);
+ g_free(error);
- slpcall->wasted = TRUE;
-
- /* msn_slpcall_destroy(slpcall); */
- return slpcall;
+ } else {
+ /* Everything's just dandy */
+ got_ok(slpcall, content_type, content);
}
- content_type = get_token(body, "Content-Type: ", "\r\n");
-
- content = get_token(body, "\r\n\r\n", NULL);
-
- got_ok(slpcall, content_type, content);
-
g_free(content_type);
g_free(content);
}
More information about the Commits
mailing list