提交 f1f76ba4 编写于 作者: C chegar

6594296: NetworkInterface.getHardwareAddress returns zero length byte array

Reviewed-by: alanb
上级 0643f6c8
......@@ -818,10 +818,12 @@ JNIEXPORT jbyteArray JNICALL Java_java_net_NetworkInterface_getMacAddr0_XP
ptr = getAdapter(env, index);
if (ptr != NULL) {
len = ptr->PhysicalAddressLength;
ret = (*env)->NewByteArray(env, len);
if (!IS_NULL(ret)) {
(*env)->SetByteArrayRegion(env, ret, 0, len,
(jbyte*) ptr->PhysicalAddress);
if (len > 0) {
ret = (*env)->NewByteArray(env, len);
if (!IS_NULL(ret)) {
(*env)->SetByteArrayRegion(env, ret, 0, len,
(jbyte*) ptr->PhysicalAddress);
}
}
free(ptr);
}
......
......@@ -21,9 +21,9 @@
* questions.
*/
/* @test 01/02/14
* @bug 4405354
* @summary Exercise java.net.NetworkInterface
/* @test
* @bug 4405354 6594296
* @summary Basic tests for NetworkInterface
*/
import java.net.NetworkInterface;
import java.net.InetAddress;
......@@ -69,6 +69,12 @@ public class Test {
throw new Exception("hashCode contract broken");
}
System.out.println("hashCode() test passed.");
byte[] ba = ni.getHardwareAddress();
if (ba != null && ba.length == 0) {
throw new Exception("getHardwareAddress returned 0 length byte array");
}
System.out.println("getHardwareAddress() test passed.");
}
// misc tests :-
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册