- if (!(tlvlist = aim_readtlvchain(command->data+10, command->commandlen-10)))
- {
- printf("libfaim: major bug: unable to read tlvchain from redirect\n");
- return ret;
- }
-
- if (!(tmptlv = aim_gettlv(tlvlist, 0x000d, 1)))
- {
- printf("libfaim: major bug: no service ID in tlvchain from redirect\n");
- aim_freetlvchain(&tlvlist);
- return ret;
- }
- serviceid = aimutil_get16(tmptlv->value);
-
- if (!(ip = aim_gettlv_str(tlvlist, 0x0005, 1)))
- {
- printf("libfaim: major bug: no IP in tlvchain from redirect (service 0x%02x)\n", serviceid);
- free(ip);
- aim_freetlvchain(&tlvlist);
- return ret;
- }
-
- if (!(tmptlv = aim_gettlv(tlvlist, 0x0006, 1)))
- {
- printf("libfaim: major bug: no cookie in tlvchain from redirect (service 0x%02x)\n", serviceid);
- free(ip);
- aim_freetlvchain(&tlvlist);
- return ret;
- }
- memcpy(cookie, tmptlv->value, AIM_COOKIELEN);
-
- if (serviceid == AIM_CONN_TYPE_CHAT)
- {
- /*
- * Chat hack.
- *
- */
- userfunc = aim_callhandler(command->conn, 0x0001, 0x0005);
- if (userfunc)
- ret = userfunc(sess, command, serviceid, ip, cookie, sess->pendingjoin, (int)sess->pendingjoinexchange);
+ tlvlist = aim_readtlvchain(command->data+10, command->commandlen-10);
+
+ if (aim_gettlv(tlvlist, 0x000d, 1))
+ serviceid = aim_gettlv16(tlvlist, 0x000d, 1);
+ if (aim_gettlv(tlvlist, 0x0005, 1))
+ ip = aim_gettlv_str(tlvlist, 0x0005, 1);
+ if (aim_gettlv(tlvlist, 0x0006, 1))
+ cookie = aim_gettlv_str(tlvlist, 0x0006, 1);
+
+ if ((serviceid == AIM_CONN_TYPE_CHAT) && sess->pendingjoin) {
+
+ /*
+ * Chat hack.
+ *
+ */
+ if ((userfunc = aim_callhandler(command->conn, 0x0001, 0x0005)))
+ ret = userfunc(sess, command, serviceid, ip, cookie, sess->pendingjoin, (int)sess->pendingjoinexchange);