CRITICAL NIO FLAW FOUND
And I did the leg work again here and put in ~4 hours to reduce the
bug to a most fundamental example that should be a unit test in
Android. That it is not and this bug made it to production / shipping
is amazing.
On all Java platforms 1.4, 5.0, 6.0 and Android OS version 1.0 - 2.3
the value of index 1 of buffer & buffer2 is 0x10000 (65535). On
Android 3.0 / Honeycomb index 1 of buffer is 65535 and buffer 2 is
256.. Clearly a major if not critical flaw in Honeycomb for usage of
the NIO API and calling duplicate() on a Buffer. Any code using NIO
and duplicate() will likely break on Honeycomb.
Being that this is a critical flaw.. Do you guys offer rewards or is
that only security flaws? I'll take my $1,337 check or a Google I/O
ticket.
You guys do understand that the 4 hours I did to reduce this critical
bug to an easily demonstrable level I'd charge more than a Google I/O
ticket on an invoice.
To run on Android simply call com.egrsoftware.niotest.NIOTest.test()
from onCreate() of any Activity and check system output via adb logcat
or ddms.
--------------------------------------------------------------------------------------
package com.egrsoftware.niotest;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
/**
* NIOTest - Extremely simple unit test that Google should include in
Android because it catches a bug in NIO that is
* found in Android 3.0 / Honeycomb. This is a really nefarious bug as
the affected code could be networking code, any
* native JNI code, or in my case 3D rendering via the Android OpenGL
ES API. Any code using NIO and "duplicate()" is
* broken.
*
* On all Java platforms with NIO and Android versions 1.0 to 2.3 both
buffers should print out 65535. On Android /
* Honeycomb the 1st value in buffer 1 is 65535 and buffer 2 is
256!!!! Clearly a bug that any simple unit testing
* should have found. This bug affects _ALL_ code that uses the NIO
duplicate() method on a Buffer. The fall out of
* this is immense! This is a critical bug!
*/
public class NIOTest
{
private static int s_SIZE_OF_INT = 4;
public static void test()
{
IntBuffer buffer = ByteBuffer.allocateDirect(1 *
s_SIZE_OF_INT).order(
ByteOrder.nativeOrder()).asIntBuffer();
IntBuffer buffer2 = ByteBuffer.allocateDirect(1 *
s_SIZE_OF_INT).order(
ByteOrder.nativeOrder()).asIntBuffer();
IntBuffer bufferWrite2 = buffer2.duplicate();
buffer.put(0, 0x10000); //put 65535
bufferWrite2.put(0, 0x10000);
System.err.println("NIOTest ----------");
System.err.println("buffer.get(): " +buffer.get());
System.err.println("buffer2.get(): " +buffer2.get());
}
public static void main(String args[])
{
test();
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en