Changeset e374dee for libfaim/auth.c


Ignore:
Timestamp:
Oct 10, 2003, 5:12:30 PM (21 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
fe6f1d3
Parents:
f4d0975
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfaim/auth.c

    r862371b re374dee  
    88
    99#define FAIM_INTERNAL
    10 #include <aim.h> 
     10#include <aim.h>
    1111
    1212#include "md5.h"
    1313
    14 static int aim_encode_password(const char *password, unsigned char *encoded);
     14static int aim_encode_password(const char *password, fu8_t *encoded);
    1515
    1616/*
     
    2222 *
    2323 */
    24 faim_export int aim_sendcookie(aim_session_t *sess, aim_conn_t *conn, const fu8_t *chipsahoy)
     24faim_export int aim_sendcookie(aim_session_t *sess, aim_conn_t *conn, const fu16_t length, const fu8_t *chipsahoy)
    2525{
    2626        aim_frame_t *fr;
    2727        aim_tlvlist_t *tl = NULL;
    2828
    29         if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x0001, 4+2+2+AIM_COOKIELEN)))
     29        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x0001, 4+2+2+length)))
    3030                return -ENOMEM;
    3131
    3232        aimbs_put32(&fr->data, 0x00000001);
    33         aim_addtlvtochain_raw(&tl, 0x0006, AIM_COOKIELEN, chipsahoy);   
     33        aim_addtlvtochain_raw(&tl, 0x0006, length, chipsahoy);
    3434        aim_writetlvchain(&fr->data, &tl);
    3535        aim_freetlvchain(&tl);
     
    157157        aim_frame_t *fr;
    158158        aim_tlvlist_t *tl = NULL;
    159         char *password_encoded;
    160 
    161         if (!(password_encoded = (char *) malloc(strlen(password))))
     159        int passwdlen;
     160        fu8_t *password_encoded;
     161
     162        passwdlen = strlen(password);
     163        if (!(password_encoded = (char *)malloc(passwdlen+1)))
    162164                return -ENOMEM;
     165        if (passwdlen > MAXICQPASSLEN)
     166                passwdlen = MAXICQPASSLEN;
    163167
    164168        if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 1152))) {
     
    171175        aimbs_put32(&fr->data, 0x00000001); /* FLAP Version */
    172176        aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), sn);
    173         aim_addtlvtochain_raw(&tl, 0x0002, strlen(password), password_encoded);
     177        aim_addtlvtochain_raw(&tl, 0x0002, passwdlen, password_encoded);
    174178
    175179        if (ci->clientstring)
     
    180184        aim_addtlvtochain16(&tl, 0x0019, (fu16_t)ci->point);
    181185        aim_addtlvtochain16(&tl, 0x001a, (fu16_t)ci->build);
    182         aim_addtlvtochain32(&tl, 0x0014, 0x00000055); /* distribution chan */
     186        aim_addtlvtochain32(&tl, 0x0014, (fu32_t)ci->distrib); /* distribution chan */
    183187        aim_addtlvtochain_raw(&tl, 0x000f, strlen(ci->lang), ci->lang);
    184188        aim_addtlvtochain_raw(&tl, 0x000e, strlen(ci->country), ci->country);
     
    202206 * then the client information you send here must exactly match the
    203207 * executable that you're pulling the data from.
    204  *
    205  * WinAIM 4.8.2540
    206  *   clientstring = "AOL Instant Messenger (SM), version 4.8.2540/WIN32"
    207  *   clientid = 0x0109
    208  *   major = 0x0004
    209  *   minor = 0x0008
    210  *   point = 0x0000
    211  *   build = 0x09ec
    212  *   t(0x0014) = 0x000000af
    213  *   t(0x004a) = 0x01
    214  *
    215  * WinAIM 4.3.2188:
    216  *   clientstring = "AOL Instant Messenger (SM), version 4.3.2188/WIN32"
    217  *   clientid = 0x0109
    218  *   major = 0x0400
    219  *   minor = 0x0003
    220  *   point = 0x0000
    221  *   build = 0x088c
    222  *   unknown = 0x00000086
    223  *   lang = "en"
    224  *   country = "us"
    225  *   unknown4a = 0x01
    226  *
    227  * Latest WinAIM that libfaim can emulate without server-side buddylists:
    228  *   clientstring = "AOL Instant Messenger (SM), version 4.1.2010/WIN32"
    229  *   clientid = 0x0004
    230  *   major  = 0x0004
    231  *   minor  = 0x0001
    232  *   point = 0x0000
    233  *   build  = 0x07da
    234  *   unknown= 0x0000004b
    235  *
    236  * WinAIM 3.5.1670:
    237  *   clientstring = "AOL Instant Messenger (SM), version 3.5.1670/WIN32"
    238  *   clientid = 0x0004
    239  *   major =  0x0003
    240  *   minor =  0x0005
    241  *   point = 0x0000
    242  *   build =  0x0686
    243  *   unknown =0x0000002a
    244208 *
    245209 * Java AIM 1.1.19:
     
    304268        aim_addtlvtochain16(&tl, 0x0019, (fu16_t)ci->point);
    305269        aim_addtlvtochain16(&tl, 0x001a, (fu16_t)ci->build);
     270        aim_addtlvtochain32(&tl, 0x0014, (fu32_t)ci->distrib);
    306271        aim_addtlvtochain_raw(&tl, 0x000e, strlen(ci->country), ci->country);
    307272        aim_addtlvtochain_raw(&tl, 0x000f, strlen(ci->lang), ci->lang);
    308273
     274#ifndef NOSSI
    309275        /*
    310276         * If set, old-fashioned buddy lists will not work. You will need
     
    312278         */
    313279        aim_addtlvtochain8(&tl, 0x004a, 0x01);
     280#endif
    314281
    315282        aim_writetlvchain(&fr->data, &tl);
     
    388355        aim_tlvlist_t *tlvlist;
    389356        aim_rxcallback_t userfunc;
    390         struct aim_authresp_info info;
     357        struct aim_authresp_info *info;
    391358        int ret = 0;
    392359
    393         memset(&info, 0, sizeof(info));
     360        info = (struct aim_authresp_info *)malloc(sizeof(struct aim_authresp_info));
     361        memset(info, 0, sizeof(struct aim_authresp_info));
    394362
    395363        /*
     
    404372        memset(sess->sn, 0, sizeof(sess->sn));
    405373        if (aim_gettlv(tlvlist, 0x0001, 1)) {
    406                 info.sn = aim_gettlv_str(tlvlist, 0x0001, 1);
    407                 strncpy(sess->sn, info.sn, sizeof(sess->sn));
     374                info->sn = aim_gettlv_str(tlvlist, 0x0001, 1);
     375                strncpy(sess->sn, info->sn, sizeof(sess->sn));
    408376        }
    409377
     
    413381         */
    414382        if (aim_gettlv(tlvlist, 0x0008, 1))
    415                 info.errorcode = aim_gettlv16(tlvlist, 0x0008, 1);
     383                info->errorcode = aim_gettlv16(tlvlist, 0x0008, 1);
    416384        if (aim_gettlv(tlvlist, 0x0004, 1))
    417                 info.errorurl = aim_gettlv_str(tlvlist, 0x0004, 1);
     385                info->errorurl = aim_gettlv_str(tlvlist, 0x0004, 1);
    418386
    419387        /*
     
    421389         */
    422390        if (aim_gettlv(tlvlist, 0x0005, 1))
    423                 info.bosip = aim_gettlv_str(tlvlist, 0x0005, 1);
     391                info->bosip = aim_gettlv_str(tlvlist, 0x0005, 1);
    424392
    425393        /*
     
    431399                tmptlv = aim_gettlv(tlvlist, 0x0006, 1);
    432400
    433                 info.cookie = tmptlv->value;
     401                info->cookielen = tmptlv->length;
     402                info->cookie = tmptlv->value;
    434403        }
    435404
    436405        /*
    437406         * The email address attached to this account
    438          *   Not available for ICQ logins.
     407         *   Not available for ICQ or @mac.com logins.
     408         *   If you receive this TLV, then you are allowed to use
     409         *   family 0x0018 to check the status of your email.
     410         * XXX - Not really true!
    439411         */
    440412        if (aim_gettlv(tlvlist, 0x0011, 1))
    441                 info.email = aim_gettlv_str(tlvlist, 0x0011, 1);
     413                info->email = aim_gettlv_str(tlvlist, 0x0011, 1);
    442414
    443415        /*
    444416         * The registration status.  (Not real sure what it means.)
    445          *   Not available for ICQ logins.
     417         *   Not available for ICQ or @mac.com logins.
    446418         *
    447419         *   1 = No disclosure
     
    452424         * to other users or not.  AFAIK, this feature is no longer used.
    453425         *
     426         * Means you can use the admin family? (0x0007)
     427         *
    454428         */
    455429        if (aim_gettlv(tlvlist, 0x0013, 1))
    456                 info.regstatus = aim_gettlv16(tlvlist, 0x0013, 1);
     430                info->regstatus = aim_gettlv16(tlvlist, 0x0013, 1);
    457431
    458432        if (aim_gettlv(tlvlist, 0x0040, 1))
    459                 info.latestbeta.build = aim_gettlv32(tlvlist, 0x0040, 1);
     433                info->latestbeta.build = aim_gettlv32(tlvlist, 0x0040, 1);
    460434        if (aim_gettlv(tlvlist, 0x0041, 1))
    461                 info.latestbeta.url = aim_gettlv_str(tlvlist, 0x0041, 1);
     435                info->latestbeta.url = aim_gettlv_str(tlvlist, 0x0041, 1);
    462436        if (aim_gettlv(tlvlist, 0x0042, 1))
    463                 info.latestbeta.info = aim_gettlv_str(tlvlist, 0x0042, 1);
     437                info->latestbeta.info = aim_gettlv_str(tlvlist, 0x0042, 1);
    464438        if (aim_gettlv(tlvlist, 0x0043, 1))
    465                 info.latestbeta.name = aim_gettlv_str(tlvlist, 0x0043, 1);
     439                info->latestbeta.name = aim_gettlv_str(tlvlist, 0x0043, 1);
    466440        if (aim_gettlv(tlvlist, 0x0048, 1))
    467441                ; /* no idea what this is */
    468442
    469443        if (aim_gettlv(tlvlist, 0x0044, 1))
    470                 info.latestrelease.build = aim_gettlv32(tlvlist, 0x0044, 1);
     444                info->latestrelease.build = aim_gettlv32(tlvlist, 0x0044, 1);
    471445        if (aim_gettlv(tlvlist, 0x0045, 1))
    472                 info.latestrelease.url = aim_gettlv_str(tlvlist, 0x0045, 1);
     446                info->latestrelease.url = aim_gettlv_str(tlvlist, 0x0045, 1);
    473447        if (aim_gettlv(tlvlist, 0x0046, 1))
    474                 info.latestrelease.info = aim_gettlv_str(tlvlist, 0x0046, 1);
     448                info->latestrelease.info = aim_gettlv_str(tlvlist, 0x0046, 1);
    475449        if (aim_gettlv(tlvlist, 0x0047, 1))
    476                 info.latestrelease.name = aim_gettlv_str(tlvlist, 0x0047, 1);
     450                info->latestrelease.name = aim_gettlv_str(tlvlist, 0x0047, 1);
    477451        if (aim_gettlv(tlvlist, 0x0049, 1))
    478452                ; /* no idea what this is */
     
    482456         */
    483457        if (aim_gettlv(tlvlist, 0x0054, 1))
    484                 info.chpassurl = aim_gettlv_str(tlvlist, 0x0054, 1);
     458                info->chpassurl = aim_gettlv_str(tlvlist, 0x0054, 1);
     459
     460        /*
     461         * Unknown.  Seen on an @mac.com screen name with value of 0x003f
     462         */
     463        if (aim_gettlv(tlvlist, 0x0055, 1))
     464                ;
     465
     466        sess->authinfo = info;
    485467
    486468        if ((userfunc = aim_callhandler(sess, rx->conn, snac ? snac->family : 0x0017, snac ? snac->subtype : 0x0003)))
    487                 ret = userfunc(sess, rx, &info);
    488 
    489         free(info.sn);
    490         free(info.bosip);
    491         free(info.errorurl);
    492         free(info.email);
    493         free(info.chpassurl);
    494         free(info.latestrelease.name);
    495         free(info.latestrelease.url);
    496         free(info.latestrelease.info);
    497         free(info.latestbeta.name);
    498         free(info.latestbeta.url);
    499         free(info.latestbeta.info);
     469                ret = userfunc(sess, rx, info);
    500470
    501471        aim_freetlvchain(&tlvlist);
     
    520490        keystr = aimbs_getstr(bs, keylen);
    521491
     492        /* XXX - When GiantGrayPanda signed on AIM I got a thing asking me to register
     493         * for the netscape network.  This SNAC had a type 0x0058 TLV with length 10. 
     494         * Data is 0x0007 0004 3e19 ae1e 0006 0004 0000 0005 */
     495
    522496        if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
    523497                ret = userfunc(sess, rx, keystr);
     
    526500
    527501        return ret;
     502}
     503
     504static void auth_shutdown(aim_session_t *sess, aim_module_t *mod)
     505{
     506        if (sess->authinfo) {
     507                free(sess->authinfo->sn);
     508                free(sess->authinfo->bosip);
     509                free(sess->authinfo->errorurl);
     510                free(sess->authinfo->email);
     511                free(sess->authinfo->chpassurl);
     512                free(sess->authinfo->latestrelease.name);
     513                free(sess->authinfo->latestrelease.url);
     514                free(sess->authinfo->latestrelease.info);
     515                free(sess->authinfo->latestbeta.name);
     516                free(sess->authinfo->latestbeta.url);
     517                free(sess->authinfo->latestbeta.info);
     518                free(sess->authinfo);
     519        }
    528520}
    529521
     
    547539        strncpy(mod->name, "auth", sizeof(mod->name));
    548540        mod->snachandler = snachandler;
    549 
    550         return 0;
    551 }
     541        mod->shutdown = auth_shutdown;
     542
     543        return 0;
     544}
Note: See TracChangeset for help on using the changeset viewer.