Changeset e374dee for libfaim/auth.c
- Timestamp:
- Oct 10, 2003, 5:12:30 PM (21 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfaim/auth.c
r862371b re374dee 8 8 9 9 #define FAIM_INTERNAL 10 #include <aim.h> 10 #include <aim.h> 11 11 12 12 #include "md5.h" 13 13 14 static int aim_encode_password(const char *password, unsigned char*encoded);14 static int aim_encode_password(const char *password, fu8_t *encoded); 15 15 16 16 /* … … 22 22 * 23 23 */ 24 faim_export int aim_sendcookie(aim_session_t *sess, aim_conn_t *conn, const fu 8_t *chipsahoy)24 faim_export int aim_sendcookie(aim_session_t *sess, aim_conn_t *conn, const fu16_t length, const fu8_t *chipsahoy) 25 25 { 26 26 aim_frame_t *fr; 27 27 aim_tlvlist_t *tl = NULL; 28 28 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))) 30 30 return -ENOMEM; 31 31 32 32 aimbs_put32(&fr->data, 0x00000001); 33 aim_addtlvtochain_raw(&tl, 0x0006, AIM_COOKIELEN, chipsahoy);33 aim_addtlvtochain_raw(&tl, 0x0006, length, chipsahoy); 34 34 aim_writetlvchain(&fr->data, &tl); 35 35 aim_freetlvchain(&tl); … … 157 157 aim_frame_t *fr; 158 158 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))) 162 164 return -ENOMEM; 165 if (passwdlen > MAXICQPASSLEN) 166 passwdlen = MAXICQPASSLEN; 163 167 164 168 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x01, 1152))) { … … 171 175 aimbs_put32(&fr->data, 0x00000001); /* FLAP Version */ 172 176 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); 174 178 175 179 if (ci->clientstring) … … 180 184 aim_addtlvtochain16(&tl, 0x0019, (fu16_t)ci->point); 181 185 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 */ 183 187 aim_addtlvtochain_raw(&tl, 0x000f, strlen(ci->lang), ci->lang); 184 188 aim_addtlvtochain_raw(&tl, 0x000e, strlen(ci->country), ci->country); … … 202 206 * then the client information you send here must exactly match the 203 207 * executable that you're pulling the data from. 204 *205 * WinAIM 4.8.2540206 * clientstring = "AOL Instant Messenger (SM), version 4.8.2540/WIN32"207 * clientid = 0x0109208 * major = 0x0004209 * minor = 0x0008210 * point = 0x0000211 * build = 0x09ec212 * t(0x0014) = 0x000000af213 * t(0x004a) = 0x01214 *215 * WinAIM 4.3.2188:216 * clientstring = "AOL Instant Messenger (SM), version 4.3.2188/WIN32"217 * clientid = 0x0109218 * major = 0x0400219 * minor = 0x0003220 * point = 0x0000221 * build = 0x088c222 * unknown = 0x00000086223 * lang = "en"224 * country = "us"225 * unknown4a = 0x01226 *227 * Latest WinAIM that libfaim can emulate without server-side buddylists:228 * clientstring = "AOL Instant Messenger (SM), version 4.1.2010/WIN32"229 * clientid = 0x0004230 * major = 0x0004231 * minor = 0x0001232 * point = 0x0000233 * build = 0x07da234 * unknown= 0x0000004b235 *236 * WinAIM 3.5.1670:237 * clientstring = "AOL Instant Messenger (SM), version 3.5.1670/WIN32"238 * clientid = 0x0004239 * major = 0x0003240 * minor = 0x0005241 * point = 0x0000242 * build = 0x0686243 * unknown =0x0000002a244 208 * 245 209 * Java AIM 1.1.19: … … 304 268 aim_addtlvtochain16(&tl, 0x0019, (fu16_t)ci->point); 305 269 aim_addtlvtochain16(&tl, 0x001a, (fu16_t)ci->build); 270 aim_addtlvtochain32(&tl, 0x0014, (fu32_t)ci->distrib); 306 271 aim_addtlvtochain_raw(&tl, 0x000e, strlen(ci->country), ci->country); 307 272 aim_addtlvtochain_raw(&tl, 0x000f, strlen(ci->lang), ci->lang); 308 273 274 #ifndef NOSSI 309 275 /* 310 276 * If set, old-fashioned buddy lists will not work. You will need … … 312 278 */ 313 279 aim_addtlvtochain8(&tl, 0x004a, 0x01); 280 #endif 314 281 315 282 aim_writetlvchain(&fr->data, &tl); … … 388 355 aim_tlvlist_t *tlvlist; 389 356 aim_rxcallback_t userfunc; 390 struct aim_authresp_info info;357 struct aim_authresp_info *info; 391 358 int ret = 0; 392 359 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)); 394 362 395 363 /* … … 404 372 memset(sess->sn, 0, sizeof(sess->sn)); 405 373 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)); 408 376 } 409 377 … … 413 381 */ 414 382 if (aim_gettlv(tlvlist, 0x0008, 1)) 415 info .errorcode = aim_gettlv16(tlvlist, 0x0008, 1);383 info->errorcode = aim_gettlv16(tlvlist, 0x0008, 1); 416 384 if (aim_gettlv(tlvlist, 0x0004, 1)) 417 info .errorurl = aim_gettlv_str(tlvlist, 0x0004, 1);385 info->errorurl = aim_gettlv_str(tlvlist, 0x0004, 1); 418 386 419 387 /* … … 421 389 */ 422 390 if (aim_gettlv(tlvlist, 0x0005, 1)) 423 info .bosip = aim_gettlv_str(tlvlist, 0x0005, 1);391 info->bosip = aim_gettlv_str(tlvlist, 0x0005, 1); 424 392 425 393 /* … … 431 399 tmptlv = aim_gettlv(tlvlist, 0x0006, 1); 432 400 433 info.cookie = tmptlv->value; 401 info->cookielen = tmptlv->length; 402 info->cookie = tmptlv->value; 434 403 } 435 404 436 405 /* 437 406 * 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! 439 411 */ 440 412 if (aim_gettlv(tlvlist, 0x0011, 1)) 441 info .email = aim_gettlv_str(tlvlist, 0x0011, 1);413 info->email = aim_gettlv_str(tlvlist, 0x0011, 1); 442 414 443 415 /* 444 416 * The registration status. (Not real sure what it means.) 445 * Not available for ICQ logins.417 * Not available for ICQ or @mac.com logins. 446 418 * 447 419 * 1 = No disclosure … … 452 424 * to other users or not. AFAIK, this feature is no longer used. 453 425 * 426 * Means you can use the admin family? (0x0007) 427 * 454 428 */ 455 429 if (aim_gettlv(tlvlist, 0x0013, 1)) 456 info .regstatus = aim_gettlv16(tlvlist, 0x0013, 1);430 info->regstatus = aim_gettlv16(tlvlist, 0x0013, 1); 457 431 458 432 if (aim_gettlv(tlvlist, 0x0040, 1)) 459 info .latestbeta.build = aim_gettlv32(tlvlist, 0x0040, 1);433 info->latestbeta.build = aim_gettlv32(tlvlist, 0x0040, 1); 460 434 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); 462 436 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); 464 438 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); 466 440 if (aim_gettlv(tlvlist, 0x0048, 1)) 467 441 ; /* no idea what this is */ 468 442 469 443 if (aim_gettlv(tlvlist, 0x0044, 1)) 470 info .latestrelease.build = aim_gettlv32(tlvlist, 0x0044, 1);444 info->latestrelease.build = aim_gettlv32(tlvlist, 0x0044, 1); 471 445 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); 473 447 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); 475 449 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); 477 451 if (aim_gettlv(tlvlist, 0x0049, 1)) 478 452 ; /* no idea what this is */ … … 482 456 */ 483 457 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; 485 467 486 468 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); 500 470 501 471 aim_freetlvchain(&tlvlist); … … 520 490 keystr = aimbs_getstr(bs, keylen); 521 491 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 522 496 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) 523 497 ret = userfunc(sess, rx, keystr); … … 526 500 527 501 return ret; 502 } 503 504 static 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 } 528 520 } 529 521 … … 547 539 strncpy(mod->name, "auth", sizeof(mod->name)); 548 540 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.