From cfbecc914ca34f313302186d4d3f716f9137c431 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 6 Jan 2013 12:09:35 +0000 Subject: Fixed NULL pointer dereference bug when newly connecting to identi.ca. Twitter sends us our real username on OAuth completion, which is then used instead of the username supplied by the user. Identi.ca doesn't supply this info so BitlBee would instead replace td->user with a NULL pointer. --- protocols/twitter/twitter.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'protocols') diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index 651bf345..8d437ed1 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -192,17 +192,18 @@ static gboolean twitter_oauth_callback(struct oauth_info *info) imcb_buddy_msg(ic, name, msg, 0, 0); g_free(msg); } else if (info->stage == OAUTH_ACCESS_TOKEN) { + const char *sn; + if (info->token == NULL || info->token_secret == NULL) { imcb_error(ic, "OAuth error: %s", twitter_parse_error(info->http)); imc_logout(ic, TRUE); return FALSE; - } else { - const char *sn = oauth_params_get(&info->params, "screen_name"); - - if (sn != NULL && ic->acc->prpl->handle_cmp(sn, ic->acc->user) != 0) { + } + + if ((sn = oauth_params_get(&info->params, "screen_name"))) { + if (ic->acc->prpl->handle_cmp(sn, ic->acc->user) != 0) imcb_log(ic, "Warning: You logged in via OAuth as %s " - "instead of %s.", sn, ic->acc->user); - } + "instead of %s.", sn, ic->acc->user); g_free(td->user); td->user = g_strdup(sn); } -- cgit v1.2.3