alminah / android-rcs-ims-stack

Automatically exported from code.google.com/p/android-rcs-ims-stack
0 stars 0 forks source link

Exception in receiving file transfer if header byte-range is in format like 1-*/123456 #182

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Initiate a file transfer
2.Has the server configured to send byte-range in format <offset>-*/<total> or 
change the code to return 0 in MsrpUtils.getChunkSize()

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
2.5.10

Please provide any additional information below.

In ChunkReceiver, buffer_length is never set to a value but initialized as 0.
In readChunkedData(), buffer is allocated only enough memory for the end tag 
because buffer_length is 0.
As a result, once it starts reading from the stream, it will quickly throw an 
ArrayIndexOutOfBoundException when adding more byte to buffer.

A quick fix is to initialize buffer_length to MsrpConstans.CHUNK_MAX_SIZE or 
max size that the receiver expect. However, it will still cause exception if 
sender or server sends a larger chunk.

Original issue reported on code.google.com by mcd...@mcdull.us on 15 Nov 2013 at 10:10

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I just saw Issue 112, it is a duplicate of that issue

Original comment by mcd...@mcdull.us on 20 Nov 2013 at 11:12

GoogleCodeExporter commented 9 years ago
Fixed
Note: in the last chunk, the end value must be equal to the total size

Original comment by lemordan...@gmail.com on 8 Jan 2014 at 3:05

GoogleCodeExporter commented 9 years ago
Current implementation is limited to chunks of size 
MsrpConstants.CHUNK_MAX_SIZE which is a local value (although taken from RCSe 
implementation guideline). I would suggest to use a rather dynamic buffer size 
which equals to the total size of the whole message.

Original comment by andreas-...@telekom.de on 28 Jan 2014 at 9:35

GoogleCodeExporter commented 9 years ago
I'll provide a change as proposed by Philippe yesterday which will be a mixture 
of a dynamic buffer size (coming from the real file size) and a fallback to a 
fixed buffer size if that would lead to an out of memory exception.

Original comment by andreas-...@telekom.de on 30 Jan 2014 at 7:46