[Red5] bug with added handshake in svn

Mikko Rantalainen mikko.rantalainen at peda.net
Mon Aug 4 06:53:19 PDT 2008


Daniel Rossi wrote:
> Here is the possible problem
> 
> int index = (inputArray[8] + inputArray[9] + inputArray[10] +  
> inputArray[11]) % 728 + 12;
> 		System.out.println(index);
> 		System.out.println(inputArray.length);
> 		System.arraycopy(inputArray, index, part, 0, 32);
> 
> -55
> 1536
> [WARN] [pool-4-thread-1] org.red5.server.net.rtmp.RTMPMinaIoHandler -  
> [/0:0:0:0:0:0:0:1%0:51595] EXCEPTION:
> java.lang.ArrayIndexOutOfBoundsException
> 
> index is -55 ???

Without knowing anything else about the contents of inputArray above,
I'd guess that the original coder expected expression (...) % 728 to be
in range from 0 to 727. However, it really is in range from -727 to 727.
As a result, a negative index is possible.

See also: http://mindprod.com/jgloss/modulus.html

-- 
Mikko


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : http://osflash.org/pipermail/red5_osflash.org/attachments/20080804/11e5e43a/attachment.bin 


More information about the Red5 mailing list