[asterisk-bugs] [JIRA] (ASTERISK-20745) In MESSAGE received over WebSocket, the body last char is cut
Pedro Kiefer (JIRA)
noreply at issues.asterisk.org
Wed Nov 28 10:31:45 CST 2012
[ https://issues.asterisk.org/jira/browse/ASTERISK-20745?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=200197#comment-200197 ]
Pedro Kiefer commented on ASTERISK-20745:
-----------------------------------------
Dumping data on the end of ast_websocket_read gives me:
{noformat}
------
Length: 0x231, iter: 24
0000 4D 45 53 53 41 47 45 20 73 69 70 3A 31 31 31 31 MESSAGE sip:1111
0010 40 31 37 32 2E 32 30 2E 33 31 2E 31 33 34 20 53 @172.20.31.134 S
0020 49 50 2F 32 2E 30 0D 0A 52 6F 75 74 65 3A 20 3C IP/2.0..Route: <
0030 73 69 70 3A 31 37 32 2E 32 30 2E 33 31 2E 31 33 sip:172.20.31.13
0040 34 3A 38 30 38 38 3B 74 72 61 6E 73 70 6F 72 74 4:8088;transport
0050 3D 77 73 3B 6C 72 3E 0D 0A 56 69 61 3A 20 53 49 =ws;lr>..Via: SI
0060 50 2F 32 2E 30 2F 54 43 50 20 32 34 2E 31 30 39 P/2.0/TCP 24.109
0070 2E 32 38 2E 32 33 3B 62 72 61 6E 63 68 3D 7A 39 .28.23;branch=z9
0080 68 47 34 62 4B 34 34 31 31 33 32 38 0D 0A 4D 61 hG4bK4411328..Ma
0090 78 2D 46 6F 72 77 61 72 64 73 3A 20 36 39 0D 0A x-Forwards: 69..
00a0 54 6F 3A 20 73 69 70 3A 31 31 31 31 40 31 37 32 To: sip:1111 at 172
00b0 2E 32 30 2E 33 31 2E 31 33 34 0D 0A 46 72 6F 6D .20.31.134..From
00c0 3A 20 73 69 70 3A 31 32 33 36 40 31 37 32 2E 32 : sip:1236 at 172.2
00d0 30 2E 33 31 2E 31 33 34 3B 74 61 67 3D 6B 30 6D 0.31.134;tag=k0m
00e0 6D 74 77 31 31 79 6E 0D 0A 43 61 6C 6C 2D 49 44 mtw11yn..Call-ID
00f0 3A 20 64 6D 77 75 6A 31 6D 6A 6F 71 39 32 61 34 : dmwuj1mjoq92a4
0100 6A 38 75 6D 63 78 0D 0A 43 53 65 71 3A 20 34 39 j8umcx..CSeq: 49
0110 37 38 20 4D 45 53 53 41 47 45 0D 0A 41 75 74 68 78 MESSAGE..Auth
0120 6F 72 69 7A 61 74 69 6F 6E 3A 20 44 69 67 65 73 orization: Diges
0130 74 20 75 73 65 72 6E 61 6D 65 3D 22 31 32 33 36 t username="1236
0140 22 2C 72 65 61 6C 6D 3D 22 74 65 63 6E 6F 73 65 ",realm="tecnose
0150 6E 69 6F 72 2E 63 6F 6D 22 2C 6E 6F 6E 63 65 3D nior.com",nonce=
0160 22 35 34 64 62 63 62 33 37 22 2C 75 72 69 3D 22 "54dbcb37",uri="
0170 73 69 70 3A 31 31 31 31 40 31 37 32 2E 32 30 2E sip:1111 at 172.20.
0180 33 31 2E 31 33 34 22 2C 72 65 73 70 6F 6E 73 65 31.134",response
0190 3D 22 34 30 30 65 36 34 64 32 34 30 66 63 34 39 ="400e64d240fc49
01a0 30 66 34 30 62 30 63 65 35 63 64 64 39 63 39 61 0f40b0ce5cdd9c9a
01b0 62 38 22 2C 61 6C 67 6F 72 69 74 68 6D 3D 4D 44 b8",algorithm=MD
01c0 35 0D 0A 43 6F 6E 74 65 6E 74 2D 54 79 70 65 3A 5..Content-Type:
01d0 20 74 65 78 74 2F 70 6C 61 69 6E 0D 0A 53 75 70 text/plain..Sup
01e0 70 6F 72 74 65 64 3A 20 70 61 74 68 2C 20 6F 75 ported: path, ou
01f0 74 62 6F 75 6E 64 2C 20 67 72 75 75 0D 0A 55 73 tbound, gruu..Us
0200 65 72 2D 41 67 65 6E 74 3A 20 4A 73 53 49 50 20 er-Agent: JsSIP
0210 30 2E 32 2E 31 0D 0A 43 6F 6E 74 65 6E 74 2D 4C 0.2.1..Content-L
0220 65 6E 67 74 68 3A 20 35 0D 0A 0D 0A 71 77 65 72 ength: 5....qwer
0230 74 t
------
{noformat}
Doing the same thing on chan_sip, sip_websocket_callback function, right after copying the payload data to struct sip_request.data (using ast_str_create and ast_str_set). I've dumped it calling ast_str_buffer and ast_str_size. As you can notice the size is the same, but the last char is not 0x74 but 0x00.
{noformat}
******
Length: 0x231, iter: 24
0000 4D 45 53 53 41 47 45 20 73 69 70 3A 31 31 31 31 MESSAGE sip:1111
0010 40 31 37 32 2E 32 30 2E 33 31 2E 31 33 34 20 53 @172.20.31.134 S
0020 49 50 2F 32 2E 30 0D 0A 52 6F 75 74 65 3A 20 3C IP/2.0..Route: <
0030 73 69 70 3A 31 37 32 2E 32 30 2E 33 31 2E 31 33 sip:172.20.31.13
0040 34 3A 38 30 38 38 3B 74 72 61 6E 73 70 6F 72 74 4:8088;transport
0050 3D 77 73 3B 6C 72 3E 0D 0A 56 69 61 3A 20 53 49 =ws;lr>..Via: SI
0060 50 2F 32 2E 30 2F 54 43 50 20 32 34 2E 31 30 39 P/2.0/TCP 24.109
0070 2E 32 38 2E 32 33 3B 62 72 61 6E 63 68 3D 7A 39 .28.23;branch=z9
0080 68 47 34 62 4B 34 34 31 31 33 32 38 0D 0A 4D 61 hG4bK4411328..Ma
0090 78 2D 46 6F 72 77 61 72 64 73 3A 20 36 39 0D 0A x-Forwards: 69..
00a0 54 6F 3A 20 73 69 70 3A 31 31 31 31 40 31 37 32 To: sip:1111 at 172
00b0 2E 32 30 2E 33 31 2E 31 33 34 0D 0A 46 72 6F 6D .20.31.134..From
00c0 3A 20 73 69 70 3A 31 32 33 36 40 31 37 32 2E 32 : sip:1236 at 172.2
00d0 30 2E 33 31 2E 31 33 34 3B 74 61 67 3D 6B 30 6D 0.31.134;tag=k0m
00e0 6D 74 77 31 31 79 6E 0D 0A 43 61 6C 6C 2D 49 44 mtw11yn..Call-ID
00f0 3A 20 64 6D 77 75 6A 31 6D 6A 6F 71 39 32 61 34 : dmwuj1mjoq92a4
0100 6A 38 75 6D 63 78 0D 0A 43 53 65 71 3A 20 34 39 j8umcx..CSeq: 49
0110 37 38 20 4D 45 53 53 41 47 45 0D 0A 41 75 74 68 78 MESSAGE..Auth
0120 6F 72 69 7A 61 74 69 6F 6E 3A 20 44 69 67 65 73 orization: Diges
0130 74 20 75 73 65 72 6E 61 6D 65 3D 22 31 32 33 36 t username="1236
0140 22 2C 72 65 61 6C 6D 3D 22 74 65 63 6E 6F 73 65 ",realm="tecnose
0150 6E 69 6F 72 2E 63 6F 6D 22 2C 6E 6F 6E 63 65 3D nior.com",nonce=
0160 22 35 34 64 62 63 62 33 37 22 2C 75 72 69 3D 22 "54dbcb37",uri="
0170 73 69 70 3A 31 31 31 31 40 31 37 32 2E 32 30 2E sip:1111 at 172.20.
0180 33 31 2E 31 33 34 22 2C 72 65 73 70 6F 6E 73 65 31.134",response
0190 3D 22 34 30 30 65 36 34 64 32 34 30 66 63 34 39 ="400e64d240fc49
01a0 30 66 34 30 62 30 63 65 35 63 64 64 39 63 39 61 0f40b0ce5cdd9c9a
01b0 62 38 22 2C 61 6C 67 6F 72 69 74 68 6D 3D 4D 44 b8",algorithm=MD
01c0 35 0D 0A 43 6F 6E 74 65 6E 74 2D 54 79 70 65 3A 5..Content-Type:
01d0 20 74 65 78 74 2F 70 6C 61 69 6E 0D 0A 53 75 70 text/plain..Sup
01e0 70 6F 72 74 65 64 3A 20 70 61 74 68 2C 20 6F 75 ported: path, ou
01f0 74 62 6F 75 6E 64 2C 20 67 72 75 75 0D 0A 55 73 tbound, gruu..Us
0200 65 72 2D 41 67 65 6E 74 3A 20 4A 73 53 49 50 20 er-Agent: JsSIP
0210 30 2E 32 2E 31 0D 0A 43 6F 6E 74 65 6E 74 2D 4C 0.2.1..Content-L
0220 65 6E 67 74 68 3A 20 35 0D 0A 0D 0A 71 77 65 72 ength: 5....qwer
0230 00 .
******
{noformat}
> In MESSAGE received over WebSocket, the body last char is cut
> -------------------------------------------------------------
>
> Key: ASTERISK-20745
> URL: https://issues.asterisk.org/jira/browse/ASTERISK-20745
> Project: Asterisk
> Issue Type: Bug
> Security Level: None
> Components: Channels/chan_sip/WebSocket
> Affects Versions: SVN, 11.0.1
> Reporter: Iñaki Baz Castillo
>
> When Asterisk receives a SIP MESSAGE over WebSocket it cuts the last char of the body. So if for example the MESSAGE contains "Content-Length: 4" and a body with content "1234" (without quotes), the Asterisk debug console prints the body as "123", and then it forwards the MESSAGE with "123" as body.
> This bug seems not to occur when the SIP MESSAGE arrives via SIP over TCP or UDP, so it must be a bug in the SIP WebSocket layer/parser.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the asterisk-bugs
mailing list