# HG changeset patch # User ivan.komarov@soc.pidgin.im # Date 1288452630 0 # Node ID a453690ba4f414ae5a29afef4446511ffae2f37f # Parent 361f32af5147b1c4eed3caed776cb224b6172a4f 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. diff -r 361f32af5147 -r a453690ba4f4 libpurple/protocols/oscar/family_oservice.c --- a/libpurple/protocols/oscar/family_oservice.c Fri Oct 29 20:05:52 2010 +0000 +++ b/libpurple/protocols/oscar/family_oservice.c Sat Oct 30 15:30:30 2010 +0000 @@ -1041,63 +1041,45 @@ static int aim_parse_extstatus(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) { - guint16 type; - guint8 flags, length; - - type = byte_stream_get16(bs); - flags = byte_stream_get8(bs); - length = byte_stream_get8(bs); - - /* - * A flag of 0x01 could mean "this is the checksum we have for you" - * A flag of 0x40 could mean "I don't have your icon, upload it" - */ - - switch (type) { - case 0x0000: - case 0x0001: { /* buddy icon checksum */ - /* not sure what the difference between 1 and 0 is */ - guint8 *md5 = byte_stream_getraw(bs, length); + guint16 type = byte_stream_get16(bs); + if (type == 0x0000 || type == 0x0001) { + /* buddy icon checksum */ + /* not sure what the difference between 1 and 0 is */ + guint8 flags = byte_stream_get8(bs); + guint8 length = byte_stream_get8(bs); + guint8 *md5 = byte_stream_getraw(bs, length); - if ((flags == 0x00) || (flags == 0x41)) { - if (!flap_connection_getbytype(od, SNAC_FAMILY_BART) && !od->iconconnecting) { - od->iconconnecting = TRUE; - od->set_icon = TRUE; - aim_srv_requestnew(od, SNAC_FAMILY_BART); - } else { - PurpleAccount *account = purple_connection_get_account(od->gc); - PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account); - if (img == NULL) { - aim_ssi_delicon(od); - } else { - - purple_debug_info("oscar", - "Uploading icon to icon server\n"); - aim_bart_upload(od, purple_imgstore_get_data(img), - purple_imgstore_get_size(img)); - purple_imgstore_unref(img); - } - } - } else if (flags == 0x81) { + if ((flags == 0x00) || (flags == 0x41)) { + if (!flap_connection_getbytype(od, SNAC_FAMILY_BART) && !od->iconconnecting) { + od->iconconnecting = TRUE; + od->set_icon = TRUE; + aim_srv_requestnew(od, SNAC_FAMILY_BART); + } else { PurpleAccount *account = purple_connection_get_account(od->gc); PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account); - if (img == NULL) + if (img == NULL) { aim_ssi_delicon(od); - else { - aim_ssi_seticon(od, md5, length); + } else { + + purple_debug_info("oscar", + "Uploading icon to icon server\n"); + aim_bart_upload(od, purple_imgstore_get_data(img), + purple_imgstore_get_size(img)); purple_imgstore_unref(img); } } - - g_free(md5); - } break; + } else if (flags == 0x81) { + PurpleAccount *account = purple_connection_get_account(od->gc); + PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account); + if (img == NULL) + aim_ssi_delicon(od); + else { + aim_ssi_seticon(od, md5, length); + purple_imgstore_unref(img); + } + } - case 0x0002: { - /* We just set an available message? */ - /* there is a second length that is just for the message */ - char *msg = byte_stream_getstr(bs, byte_stream_get16(bs)); - g_free(msg); - } break; + g_free(md5); } return 0;