Yasin9494 / mrim-prpl

Automatically exported from code.google.com/p/mrim-prpl
0 stars 0 forks source link

Offline msg parse error leads to segfault. #70

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Error when parsing an offline message.
Ошибка при разборе оффлайн-сообщения.

Original issue reported on code.google.com by Janus.Ko...@gmail.com on 20 Jun 2011 at 10:16

GoogleCodeExporter commented 9 years ago

Original comment by Janus.Ko...@gmail.com on 20 Jun 2011 at 11:08

Attachments:

GoogleCodeExporter commented 9 years ago
Не забываем указывать версию плагина ;-)

Original comment by ostinru on 20 Jun 2011 at 11:15

GoogleCodeExporter commented 9 years ago
Agreed. 0.2.0-r310.

Original comment by Janus.Ko...@gmail.com on 20 Jun 2011 at 11:27

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Дефект из-за разных форматов сообщений от 
клиентов разных мастей и версий протокола.

Original comment by Janus.Ko...@gmail.com on 11 Aug 2011 at 8:13

GoogleCodeExporter commented 9 years ago
Вот меня сейчас больше всего интересует 
следующий момент:

Date: Thu, 11 Aug 2011 09:51:50 +0400
Subject: Offline message
X-MRIM-Flags: 00300001
Boundary: 1313064789C20776496191313064789A1842606768
Version: 1.9
--1313064789C20776496191313064789A1842606768-- 

А именно: что это за "X-MRIM-Flags: 00300001"?
У меня паранойя, или разработчики 
протокола что-то скрывают?!

Original comment by Janus.Ko...@gmail.com on 11 Aug 2011 at 9:15

GoogleCodeExporter commented 9 years ago
1. Версия 0.1.28 отправляет вот это:

Date: Fri, 12 Aug 2011 01:24:35 +0400
MIME-Version: 1.0
Content-Type: multipart/alternative; 
boundary=1313097875R10989180601313097875S1307341846
X-MRIM-Version: 1.16
X-MRIM-Flags: 00200000

--1313097875R10989180601313097875S1307341846
Content-Type: text/plain; charset=CP-1251
Content-Transfer-Encoding: 8bit

<Message text stripped.>
--1313097875R10989180601313097875S1307341846
Content-Type: application/x-mrim-rtf

--1313097875R10989180601313097875S1307341846--

Original comment by Janus.Ko...@gmail.com on 11 Aug 2011 at 9:28

GoogleCodeExporter commented 9 years ago
В одном варианте Version (0x0030 0000; 1.9),
в другом -- X-MRIM-Version (0x0020 0000; 1.16).

Я так понимаю, 1.9 -- это версия протокола, 
использованная в webagent, так?

Original comment by Janus.Ko...@gmail.com on 11 Aug 2011 at 9:31

GoogleCodeExporter commented 9 years ago
(23:26:08) mrim-prpl: [mrim_input_cb] MRIM_CS_OFFLINE_MESSAGE_ACK
(23:26:08) mrim-prpl: [mrim_receive_offline_message] Reading offline message
(23:26:08) mrim-prpl: [mrim_receive_offline_message] 'From' == 
'15963023@chat.agent'
(23:26:08) mrim-prpl: [mrim_receive_offline_message] 'Sender' == 
'ostin-mrim-test@mail.ru'
(23:26:08) mrim-prpl: [mrim_receive_offline_message] 'Date' == 'Fri, 12 Aug 
2011 23:15:57 +0400'
(23:26:08) mrim-prpl: [mrim_receive_offline_message] 'MIME-Version' == '1.0'
(23:26:08) mrim-prpl: [mrim_receive_offline_message] 'Subject' == 
'=?UTF-16LE?B?YwBvAG4AZgAzAA==?='
(23:26:08) mrim-prpl: [mrim_receive_offline_message] 'Content-Type' == 
'multipart/alternative; boundary=1313176557B19022175291313176557C712140687'
(23:26:08) mrim-prpl: [mrim_receive_offline_message] 'X-MRIM-Version' == '1.16'
(23:26:08) mrim-prpl: [mrim_receive_offline_message] 'X-MRIM-Flags' == 
'00500084'
(23:26:08) mrim-prpl: [mrim_receive_offline_message] 'X-MRIM-Multichat-Type' == 
'0'
(23:26:08) mrim-prpl: [mrim_receive_offline_message] 'Content-Type' == 
'text/plain; charset=UTF-16LE'
(23:26:08) mrim-prpl: [mrim_receive_offline_message] 
'Content-Transfer-Encoding' == 'base64'
(23:26:08) GLib: g_strsplit: assertion `string != NULL' failed

Program received signal SIGSEGV, Segmentation fault.
0x00007fffe52da46a in mrim_receive_offline_message (mrim=0x1a06300, 
    message=0x1c9da00 "From: 15963023@chat.agent\nSender: ostin-mrim-test@mail.ru\nDate: Fri, 12 Aug 2011 23:15:57 +0400\nMIME-Version: 1.0\nSubject: =?UTF-16LE?B?YwBvAG4AZgAzAA==?=\nContent-Type: multipart/alternative; boundary"...) at message.c:225
225             message_header = split[0];
(gdb) dns[8782]: nobody needs me... =(
dns[8850]: nobody needs me... =(
dns[8853]: nobody needs me... =(

(gdb) bt full
#0  0x00007fffe52da46a in mrim_receive_offline_message (mrim=0x1a06300, 
    message=0x1c9da00 "From: 15963023@chat.agent\nSender: ostin-mrim-test@mail.ru\nDate: Fri, 12 Aug 2011 23:15:57 +0400\nMIME-Version: 1.0\nSubject: =?UTF-16LE?B?YwBvAG4AZgAzAA==?=\nContent-Type: multipart/alternative; boundary"...) at message.c:225
        split = 0x0
        message_split = 0x1c9d9e0
        __func__ = "mrim_receive_offline_message"
        message_header = 0x1ca1f10 "ZgBmAGYA\n--1313176557B19022175291313176557C712140687\nContent-Type: application/x-mrim-rtf\n\n \r\n--1313176557B19022175291313176557C712140687--\r\n"
        message_body = 0x1ca20d0 "ZgBmAGYA\n--1313176557B19022175291313176557C712140687\nContent-Type: application/x-mrim-rtf\n\n \r\n--1313176557B19022175291313176557C712140687--\r\n"
        regex = 0x1c9d9b0
        match_info = 0x1c82b10
        from = 0x1ca19d0 "15963023@chat.agent"
        date_str = 0x1961bd0 "Fri, 12 Aug 2011 23:15:57 +0400"
        boundary = 0x1ca1bd0 "`\331\311\001"
        charset = 0x1ca21f0 "UTF-16LE"
        encoding = 0x1c9dde0 "base64"
        flags = 0
        date = 0
#1  0x00007fffe52e2aa6 in mrim_input_cb (data=0xc484b0, source=22, 
cond=PURPLE_INPUT_READ) at mrim.c:418
        uidl = 0x1ca1b90 "\355{EN\376\001"
        message = 0x1c9da00 "From: 15963023@chat.agent\nSender: ostin-mrim-test@mail.ru\nDate: Fri, 12 Aug 2011 23:15:57 +0400\nMIME-Version: 1.0\nSubject: =?UTF-16LE?B?YwBvAG4AZgAzAA==?=\nContent-Type: multipart/alternative; boundary"...
        pack_ack = 0x14000000
        reason = 0x2 <Address 0x2 out of bounds>
        __func__ = "mrim_input_cb"
        __PRETTY_FUNCTION__ = "mrim_input_cb"
        gc = 0xc484b0
        mrim = 0x1a06300
        pack = 0xc7b6d0

Original comment by ostinru on 12 Aug 2011 at 7:27

GoogleCodeExporter commented 9 years ago
Пошаговый проход функции:
1) X-MRIM-Flags не прошёл из-за регистра
2) для чатов новое поле Sender=email, X-MRIM-Multichat-Type='0'

219     if (boundary) {
220         gchar **message_split = g_strsplit(message_body, boundary,0);
221         g_free(message_body);
222         g_free(boundary);
224             gchar **split = g_strsplit(message_split[1],"\n\r\n", 2);
(23:55:18) GLib: g_strsplit: assertion `string != NULL' failed
225             message_header = split[0];
(gdb) print message_split
$17 = (gchar **) 0x1909790
(gdb) print message_split[1]
$18 = (gchar *) 0x0
(gdb) print message_split[0]
$19 = (
    gchar *) 0x1913200 "ZgBmAGYA\n--1313176557B19022175291313176557C712140687\nContent-Type: application/x-mrim-rtf\n\n \r\n--1313176557B19022175291313176557C712140687--\r\n"
(gdb) print message_split[2]
$20 = (gchar *) 0x75722e6c69616d <Address 0x75722e6c69616d out of bounds>
(gdb) print message_body
$21 = (
    gchar *) 0x19133c0 "ZgBmAGYA\n--1313176557B19022175291313176557C712140687\nContent-Type: application/x-mrim-rtf\n\n \r\n--1313176557B19022175291313176557C712140687--\r\n"
(gdb) next

Program received signal SIGSEGV, Segmentation fault.
0x00007fffe52da46a in mrim_receive_offline_message (mrim=0x18fdba0, 
    message=0x19134e0 "From: 15963023@chat.agent\nSender: ostin-mrim-test@mail.ru\nDate: Fri, 12 Aug 2011 23:15:57 +0400\nMIME-Version: 1.0\nSubject: =?UTF-16LE?B?YwBvAG4AZgAzAA==?=\nContent-Type: multipart/alternative; boundary"...) at message.c:225
225             message_header = split[0];
(gdb) print split
$22 = (gchar **) 0x0

Original comment by ostinru on 12 Aug 2011 at 8:05

GoogleCodeExporter commented 9 years ago
Надо переписывать разбор чуть более, чем 
почти полностью.
Всё равно, нужно первым делом получить 
значения полей X-MRIM-FLags (если есть), *Version, 
encoding= и X-MRIM-Multichat-Type, а затем вынимать 
оставшиеся поля.

Original comment by Janus.Ko...@gmail.com on 12 Aug 2011 at 9:35

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago

Original comment by sor.alexei on 26 Apr 2015 at 4:26