diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2013-01-06 12:09:35 +0000 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2013-01-06 12:09:35 +0000 |
commit | cfbecc914ca34f313302186d4d3f716f9137c431 (patch) | |
tree | 129fa0cd4f2843404f320db5464c2de8ebb9143e /protocols/twitter/twitter.c | |
parent | 62a2bf92daff0756244feb3940eeb46b66ebce6f (diff) |
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.
Diffstat (limited to 'protocols/twitter/twitter.c')
-rw-r--r-- | protocols/twitter/twitter.c | 13 |
1 files changed, 7 insertions, 6 deletions
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); } |