Mercurial > pidgin.yaz
comparison libpurple/protocols/oscar/family_oservice.c @ 31082:a453690ba4f4
Fixed the error triggered by the failing 'byte_stream_bytes_left(bs) >= len'
check in byte_stream_getstr() when called from aim_parse_extstatus().
According to http://iserverd.khstu.ru/oscar/snac_01_21.html, we were
parsing type 0x0002 packets slightly wrongly: they don't have neither
flags nor length field; we were reading too much and that caused the assertion.
Since we didn't use the data from this type of packets anyway, I just removed
the parsing of them altogether.
author | ivan.komarov@soc.pidgin.im |
---|---|
date | Sat, 30 Oct 2010 15:30:30 +0000 |
parents | 11c54d781835 |
children |
comparison
equal
deleted
inserted
replaced
31081:361f32af5147 | 31082:a453690ba4f4 |
---|---|
1039 * needs to upload an SSI buddy icon... who engineers this stuff, anyway? | 1039 * needs to upload an SSI buddy icon... who engineers this stuff, anyway? |
1040 */ | 1040 */ |
1041 static int | 1041 static int |
1042 aim_parse_extstatus(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) | 1042 aim_parse_extstatus(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
1043 { | 1043 { |
1044 guint16 type; | 1044 guint16 type = byte_stream_get16(bs); |
1045 guint8 flags, length; | 1045 if (type == 0x0000 || type == 0x0001) { |
1046 | 1046 /* buddy icon checksum */ |
1047 type = byte_stream_get16(bs); | 1047 /* not sure what the difference between 1 and 0 is */ |
1048 flags = byte_stream_get8(bs); | 1048 guint8 flags = byte_stream_get8(bs); |
1049 length = byte_stream_get8(bs); | 1049 guint8 length = byte_stream_get8(bs); |
1050 | 1050 guint8 *md5 = byte_stream_getraw(bs, length); |
1051 /* | 1051 |
1052 * A flag of 0x01 could mean "this is the checksum we have for you" | 1052 if ((flags == 0x00) || (flags == 0x41)) { |
1053 * A flag of 0x40 could mean "I don't have your icon, upload it" | 1053 if (!flap_connection_getbytype(od, SNAC_FAMILY_BART) && !od->iconconnecting) { |
1054 */ | 1054 od->iconconnecting = TRUE; |
1055 | 1055 od->set_icon = TRUE; |
1056 switch (type) { | 1056 aim_srv_requestnew(od, SNAC_FAMILY_BART); |
1057 case 0x0000: | 1057 } else { |
1058 case 0x0001: { /* buddy icon checksum */ | |
1059 /* not sure what the difference between 1 and 0 is */ | |
1060 guint8 *md5 = byte_stream_getraw(bs, length); | |
1061 | |
1062 if ((flags == 0x00) || (flags == 0x41)) { | |
1063 if (!flap_connection_getbytype(od, SNAC_FAMILY_BART) && !od->iconconnecting) { | |
1064 od->iconconnecting = TRUE; | |
1065 od->set_icon = TRUE; | |
1066 aim_srv_requestnew(od, SNAC_FAMILY_BART); | |
1067 } else { | |
1068 PurpleAccount *account = purple_connection_get_account(od->gc); | |
1069 PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account); | |
1070 if (img == NULL) { | |
1071 aim_ssi_delicon(od); | |
1072 } else { | |
1073 | |
1074 purple_debug_info("oscar", | |
1075 "Uploading icon to icon server\n"); | |
1076 aim_bart_upload(od, purple_imgstore_get_data(img), | |
1077 purple_imgstore_get_size(img)); | |
1078 purple_imgstore_unref(img); | |
1079 } | |
1080 } | |
1081 } else if (flags == 0x81) { | |
1082 PurpleAccount *account = purple_connection_get_account(od->gc); | 1058 PurpleAccount *account = purple_connection_get_account(od->gc); |
1083 PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account); | 1059 PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account); |
1084 if (img == NULL) | 1060 if (img == NULL) { |
1085 aim_ssi_delicon(od); | 1061 aim_ssi_delicon(od); |
1086 else { | 1062 } else { |
1087 aim_ssi_seticon(od, md5, length); | 1063 |
1064 purple_debug_info("oscar", | |
1065 "Uploading icon to icon server\n"); | |
1066 aim_bart_upload(od, purple_imgstore_get_data(img), | |
1067 purple_imgstore_get_size(img)); | |
1088 purple_imgstore_unref(img); | 1068 purple_imgstore_unref(img); |
1089 } | 1069 } |
1090 } | 1070 } |
1091 | 1071 } else if (flags == 0x81) { |
1092 g_free(md5); | 1072 PurpleAccount *account = purple_connection_get_account(od->gc); |
1093 } break; | 1073 PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account); |
1094 | 1074 if (img == NULL) |
1095 case 0x0002: { | 1075 aim_ssi_delicon(od); |
1096 /* We just set an available message? */ | 1076 else { |
1097 /* there is a second length that is just for the message */ | 1077 aim_ssi_seticon(od, md5, length); |
1098 char *msg = byte_stream_getstr(bs, byte_stream_get16(bs)); | 1078 purple_imgstore_unref(img); |
1099 g_free(msg); | 1079 } |
1100 } break; | 1080 } |
1081 | |
1082 g_free(md5); | |
1101 } | 1083 } |
1102 | 1084 |
1103 return 0; | 1085 return 0; |
1104 } | 1086 } |
1105 | 1087 |