Mercurial > pidgin
comparison libpurple/protocols/yahoo/libymsg.c @ 28424:c46819108809
Make checking of p2p packet with invalid id per IM instead of per packet.
author | Sulabh Mahajan <sulabh@soc.pidgin.im> |
---|---|
date | Sat, 24 Oct 2009 04:40:51 +0000 |
parents | 318ac22eb05d |
children | 335062a2d305 |
comparison
equal
deleted
inserted
replaced
28423:318ac22eb05d | 28424:c46819108809 |
---|---|
950 YahooData *yd = gc->proto_data; | 950 YahooData *yd = gc->proto_data; |
951 GSList *l = pkt->hash; | 951 GSList *l = pkt->hash; |
952 GSList *list = NULL; | 952 GSList *list = NULL; |
953 struct _yahoo_im *im = NULL; | 953 struct _yahoo_im *im = NULL; |
954 const char *imv = NULL; | 954 const char *imv = NULL; |
955 gint val_11 = 0; | |
956 | 955 |
957 account = purple_connection_get_account(gc); | 956 account = purple_connection_get_account(gc); |
958 | 957 |
959 if (pkt->status <= 1 || pkt->status == 5 || pkt->status == YAHOO_STATUS_OFFLINE) { | 958 if (pkt->status <= 1 || pkt->status == 5 || pkt->status == YAHOO_STATUS_OFFLINE) { |
960 /* messages are received with status YAHOO_STATUS_OFFLINE in case of p2p */ | 959 /* messages are received with status YAHOO_STATUS_OFFLINE in case of p2p */ |
1004 } | 1003 } |
1005 purple_debug_info("yahoo", "Message from federated (%d) buddy %s.\n", im->fed, im->fed_from); | 1004 purple_debug_info("yahoo", "Message from federated (%d) buddy %s.\n", im->fed, im->fed_from); |
1006 | 1005 |
1007 } | 1006 } |
1008 /* peer session id */ | 1007 /* peer session id */ |
1009 if (pair->key == 11) { | 1008 if (im && (pair->key == 11)) { |
1010 if (im) | 1009 /* disconnect the peer if connected through p2p and sends wrong value for session id */ |
1011 val_11 = strtol(pair->value, NULL, 10); | 1010 if( (im->fed == YAHOO_FEDERATION_NONE) && (pkt_type == YAHOO_PKT_TYPE_P2P) |
1011 && (yd->session_id != strtol(pair->value, NULL, 10)) ) | |
1012 { | |
1013 purple_debug_warning("yahoo","p2p: %s sent us message with wrong session id. Disconnecting p2p connection to peer\n", im->fed_from); | |
1014 /* remove from p2p connection lists, also calls yahoo_p2p_disconnect_destroy_data */ | |
1015 g_hash_table_remove(yd->peers, im->fed_from); | |
1016 g_free(im->fed_from); | |
1017 g_free(im); | |
1018 return; /* Not sure whether we should process remaining IMs in this packet */ | |
1019 } | |
1012 } | 1020 } |
1013 /* IMV key */ | 1021 /* IMV key */ |
1014 if (pair->key == 63) | 1022 if (pair->key == 63) |
1015 { | 1023 { |
1016 imv = pair->value; | 1024 imv = pair->value; |
1023 } else if (pkt->status == 2) { | 1031 } else if (pkt->status == 2) { |
1024 purple_notify_error(gc, NULL, | 1032 purple_notify_error(gc, NULL, |
1025 _("Your Yahoo! message did not get sent."), NULL); | 1033 _("Your Yahoo! message did not get sent."), NULL); |
1026 } | 1034 } |
1027 | 1035 |
1028 /* disconnect the peer if connected through p2p and sends wrong value for session id */ | |
1029 if( (pkt_type == YAHOO_PKT_TYPE_P2P) && (val_11 != yd->session_id) ) { | |
1030 purple_debug_warning("yahoo","p2p: %s sent us message with wrong session id. Disconnecting p2p connection to peer\n", im ? im->fed_from : "(im was null)"); | |
1031 /* remove from p2p connection lists, also calls yahoo_p2p_disconnect_destroy_data */ | |
1032 if (im) { | |
1033 g_hash_table_remove(yd->peers, im->fed_from); | |
1034 g_free(im); | |
1035 } | |
1036 return; | |
1037 } | |
1038 | |
1039 /* TODO: It seems that this check should be per IM, not global */ | 1036 /* TODO: It seems that this check should be per IM, not global */ |
1040 /* Check for the Doodle IMV */ | 1037 /* Check for the Doodle IMV */ |
1041 /* no doodle with federated buddies -- assumption??? */ | 1038 /* no doodle with federated buddies */ |
1042 if (im != NULL && imv!= NULL && im->from != NULL) | 1039 if (im != NULL && imv!= NULL && im->from != NULL) |
1043 { | 1040 { |
1044 g_hash_table_replace(yd->imvironments, g_strdup(im->from), g_strdup(imv)); | 1041 g_hash_table_replace(yd->imvironments, g_strdup(im->from), g_strdup(imv)); |
1045 | 1042 |
1046 if (strstr(imv, "doodle;") != NULL) | 1043 if (strstr(imv, "doodle;") != NULL) |