Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/sasl.c

    r71f87ba r8eb2e84  
    5555        char *s;
    5656        int sup_plain = 0, sup_digest = 0, sup_gtalk = 0, sup_fb = 0;
    57         int want_oauth = FALSE, want_hipchat = FALSE;
     57        int want_oauth = FALSE;
    5858        GString *mechs;
    5959
     
    7575
    7676        want_oauth = set_getbool(&ic->acc->set, "oauth");
    77         want_hipchat = (jd->flags & JFLAG_HIPCHAT);
    7877
    7978        mechs = g_string_new("");
     
    112111
    113112        reply = xt_new_node("auth", NULL, NULL);
    114         if (!want_hipchat) {
    115                 xt_add_attr(reply, "xmlns", XMLNS_SASL);
    116         } else {
    117                 xt_add_attr(reply, "xmlns", XMLNS_HIPCHAT);
    118         }
     113        xt_add_attr(reply, "xmlns", XMLNS_SASL);
    119114
    120115        if (sup_gtalk && want_oauth) {
     
    148143        } else if (sup_plain) {
    149144                int len;
    150                 GString *gs;
    151                 char *username;
    152 
    153                 if (!want_hipchat) {
    154                         xt_add_attr(reply, "mechanism", "PLAIN");
    155                         username = jd->username;
    156                 } else {
    157                         username = jd->me;
    158                 }
    159 
    160                 /* set an arbitrary initial size to avoid reallocations */
    161                 gs = g_string_sized_new(128);
     145
     146                xt_add_attr(reply, "mechanism", "PLAIN");
    162147
    163148                /* With SASL PLAIN in XMPP, the text should be b64(\0user\0pass) */
    164                 g_string_append_c(gs, '\0');
    165                 g_string_append(gs, username);
    166                 g_string_append_c(gs, '\0');
    167                 g_string_append(gs, ic->acc->pass);
    168                 if (want_hipchat) {
    169                         /* Hipchat's variation adds \0resource at the end */
    170                         g_string_append_c(gs, '\0');
    171                         g_string_append(gs, set_getstr(&ic->acc->set, "resource"));
    172                 }
    173 
    174                 len = gs->len;
    175                 s = g_string_free(gs, FALSE);
    176 
     149                len = strlen(jd->username) + strlen(ic->acc->pass) + 2;
     150                s = g_malloc(len + 1);
     151                s[0] = 0;
     152                strcpy(s + 1, jd->username);
     153                strcpy(s + 2 + strlen(jd->username), ic->acc->pass);
    177154                reply->text = base64_encode((unsigned char *) s, len);
    178155                reply->text_len = strlen(reply->text);
     
    420397                imcb_log(ic, "Authentication finished");
    421398                jd->flags |= JFLAG_AUTHENTICATED | JFLAG_STREAM_RESTART;
    422 
    423                 if (jd->flags & JFLAG_HIPCHAT) {
    424                         return hipchat_handle_success(ic, node);
    425                 }
    426399        } else if (strcmp(node->name, "failure") == 0) {
    427400                imcb_error(ic, "Authentication failure");
Note: See TracChangeset for help on using the changeset viewer.