From: mid Date: Fri, 30 Jun 2000 00:13:23 +0000 (+0000) Subject: - Fri Jun 30 00:04:47 UTC 2000 X-Git-Tag: rel_0_99_2~139 X-Git-Url: http://andersk.mit.edu/gitweb/libfaim.git/commitdiff_plain/13ebc4c4459f5348470886f97cad4f964cde9afb - Fri Jun 30 00:04:47 UTC 2000 - Removed the forceful ICQ-related warnings, just in case they're wrong - Added three new fields to the client info. - **REQUIRES CLIENT CHANGES -- see faimtest for new initializer - Cleaned up aim_send_login() - Put in a nice hidious fix for AOL's latest bit of the drama. See aim_readtlvchain() for the details. --- diff --git a/CHANGES b/CHANGES index dd976bc..a957327 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,14 @@ No release numbers ------------------ + - Fri Jun 30 00:04:47 UTC 2000 + - Removed the forceful ICQ-related warnings, just in case they're wrong + - Added three new fields to the client info. + - **REQUIRES CLIENT CHANGES -- see faimtest for new initializer + - Cleaned up aim_send_login() + - Put in a nice hidious fix for AOL's latest bit of the drama. See + aim_readtlvchain() for the details. + - Mon Jun 26 07:53:02 UTC 2000 - Added utils/aimdebugd for playing with things -- see the README - Added aim_im.c::aim_parse_outgoing_im(). Probably not useful diff --git a/aim_login.c b/aim_login.c index 8b3b925..1af1420 100644 --- a/aim_login.c +++ b/aim_login.c @@ -98,11 +98,9 @@ int aim_send_login (struct aim_session_t *sess, icqmode = 1; /* needs a different password encoding */ if (clientinfo && (clientinfo->major < 4)) { printf("faim: icq: version must be at least 4.30.3141 for ICQ OSCAR login\n"); - return -1; } if (strlen(password) > 8) { printf("faim: icq: password too long (8 char max)\n"); - return -1; } } @@ -135,60 +133,48 @@ int aim_send_login (struct aim_session_t *sess, curbyte+= aim_puttlv_16(newpacket->data+curbyte, 0x0009, 0x0015); #else - newpacket->commandlen = 4 + 4 + strlen(sn) + 4+strlen(password) + 6; - - newpacket->commandlen += 8; /* tlv 0x0014 */ - - if (clientinfo) { - if (strlen(clientinfo->clientstring)) - newpacket->commandlen += 4+strlen(clientinfo->clientstring); - newpacket->commandlen += 6+6+6+6; - if (strlen(clientinfo->country)) - newpacket->commandlen += 4+strlen(clientinfo->country); - if (strlen(clientinfo->lang)) - newpacket->commandlen += 4+strlen(clientinfo->lang); - } - newpacket->lock = 1; newpacket->hdr.oscar.type = 0x01; + /* + * These four bytes are actually the FLAP version information. + * They're sent here for convenience. I suppose they could + * be seperated out into a seperate FLAP, but this is where + * everyone else sends them. + */ curbyte += aimutil_put16(newpacket->data+curbyte, 0x0000); curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001); - curbyte += aimutil_put16(newpacket->data+curbyte, 0x0001); - curbyte += aimutil_put16(newpacket->data+curbyte, strlen(sn)); - curbyte += aimutil_putstr(newpacket->data+curbyte, sn, strlen(sn)); - curbyte += aimutil_put16(newpacket->data+curbyte, 0x0002); - curbyte += aimutil_put16(newpacket->data+curbyte, strlen(password)); + curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0001, strlen(sn), sn); + password_encoded = (char *) malloc(strlen(password)); aim_encode_password(password, password_encoded); - curbyte += aimutil_putstr(newpacket->data+curbyte, password_encoded, strlen(password)); + curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0002, strlen(password), password_encoded); free(password_encoded); - if (strlen(clientinfo->clientstring)) { - curbyte += aimutil_put16(newpacket->data+curbyte, 0x0003); - curbyte += aimutil_put16(newpacket->data+curbyte, strlen(clientinfo->clientstring)); - curbyte += aimutil_putstr(newpacket->data+curbyte, clientinfo->clientstring, strlen(clientinfo->clientstring)); - } - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, /*0x010a*/ 0x0004); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, clientinfo->major /*0x0001*/); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, clientinfo->minor /*0x0001*/); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, 0x0001); - curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, clientinfo->build /*0x0013*/); - - curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, 0x00000055); - - if (strlen(clientinfo->country)) { - curbyte += aimutil_put16(newpacket->data+curbyte, 0x000e); - curbyte += aimutil_put16(newpacket->data+curbyte, strlen(clientinfo->country)); - curbyte += aimutil_putstr(newpacket->data+curbyte, clientinfo->country, strlen(clientinfo->country)); - } - if (strlen(clientinfo->lang)) { - curbyte += aimutil_put16(newpacket->data+curbyte, 0x000f); - curbyte += aimutil_put16(newpacket->data+curbyte, strlen(clientinfo->lang)); - curbyte += aimutil_putstr(newpacket->data+curbyte, clientinfo->lang, strlen(clientinfo->lang)); - } + /* XXX is clientstring required by oscar? */ + if (strlen(clientinfo->clientstring)) + curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x0003, strlen(clientinfo->clientstring), clientinfo->clientstring); + + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0016, clientinfo->major2); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0017, clientinfo->major); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0018, clientinfo->minor); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x0019, clientinfo->minor2); + curbyte += aim_puttlv_16(newpacket->data+curbyte, 0x001a, clientinfo->build); + + curbyte += aim_puttlv_32(newpacket->data+curbyte, 0x0014, clientinfo->unknown); + if (strlen(clientinfo->country)) + curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000e, strlen(clientinfo->country), clientinfo->country); + else + curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000e, 2, "us"); + + if (strlen(clientinfo->lang)) + curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000f, strlen(clientinfo->lang), clientinfo->lang); + else + curbyte += aim_puttlv_str(newpacket->data+curbyte, 0x000f, 2, "en"); + + newpacket->commandlen = curbyte; #endif newpacket->lock = 0; @@ -440,11 +426,7 @@ unsigned long aim_sendredirect(struct aim_session_t *sess, tx->lock = 1; - i += aimutil_put16(tx->data+i, 0x0001); - i += aimutil_put16(tx->data+i, 0x0005); - i += aimutil_put16(tx->data+i, 0x0000); - i += aimutil_put16(tx->data+i, 0x0000); - i += aimutil_put16(tx->data+i, 0x0000); + i += aim_putsnac(tx->data+i, 0x0001, 0x0005, 0x0000, 0x00000000); aim_addtlvtochain16(&tlvlist, 0x000d, servid); aim_addtlvtochain_str(&tlvlist, 0x0005, ip, strlen(ip)); diff --git a/aim_tlv.c b/aim_tlv.c index 42d3602..1058b22 100644 --- a/aim_tlv.c +++ b/aim_tlv.c @@ -28,18 +28,30 @@ struct aim_tlvlist_t *aim_readtlvchain(u_char *buf, int maxlen) if ((pos+length) <= maxlen) { - cur = (struct aim_tlvlist_t *)malloc(sizeof(struct aim_tlvlist_t)); - memset(cur, 0x00, sizeof(struct aim_tlvlist_t)); - - cur->tlv = aim_createtlv(); - cur->tlv->type = type; - cur->tlv->length = length; - cur->tlv->value = (u_char *)malloc(length*sizeof(u_char)); - memcpy(cur->tlv->value, buf+pos, length); - - cur->next = list; - list = cur; + /* + * Okay, so now AOL has decided that any TLV of + * type 0x0013 can only be two bytes, despite + * what the actual given length is. So here + * we dump any invalid TLVs of that sort. Hopefully + * theres no special cases to this special case. + * - mid (30jun2000) + */ + if ((type == 0x0013) && (length != 0x0002)) { + printf("faim: skipping TLV t(0013) with invalid length (0x%04x)\n", length); + length = 0x0002; + } else { + cur = (struct aim_tlvlist_t *)malloc(sizeof(struct aim_tlvlist_t)); + memset(cur, 0x00, sizeof(struct aim_tlvlist_t)); + + cur->tlv = aim_createtlv(); + cur->tlv->type = type; + cur->tlv->length = length; + cur->tlv->value = (u_char *)malloc(length*sizeof(u_char)); + memcpy(cur->tlv->value, buf+pos, length); + cur->next = list; + list = cur; + } pos += length; } } diff --git a/faim/aim.h b/faim/aim.h index dce12e4..63b1a1d 100644 --- a/faim/aim.h +++ b/faim/aim.h @@ -149,6 +149,9 @@ struct client_info_s { int build; char country[3]; char lang[3]; + int major2; + int minor2; + long unknown; }; #ifndef TRUE diff --git a/utils/faimtest/faimtest.c b/utils/faimtest/faimtest.c index fc00748..7b3c07a 100644 --- a/utils/faimtest/faimtest.c +++ b/utils/faimtest/faimtest.c @@ -84,13 +84,8 @@ int main(void) struct aim_conn_t *authconn = NULL, *waitingconn = NULL; int keepgoing = 1; -#if 0 - /* Use something like this for AIM */ - struct client_info_s info = {"Boo", 2, 1, 0, "us", "en"}; -#else - /* or something exactly like this for ICQ and AIM */ - struct client_info_s info = {"Random String (libfaim)", 4, 30, 3141, "us", "en"}; -#endif + struct client_info_s info = {"FAIMtest (Hi guys!)", 4, 3, 3141, "us", "en", 0x0004, 0x0001, 0x00000055}; + int selstat = 0; if ( !(screenname = getenv("SCREENNAME")) ||