HDFS-5195. Prevent passing null pointer to mlock and munlock. Contributed by Chris Nauroth.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-4949@1523093 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2f8297215f
commit
1a1f49fa4f
|
@ -363,6 +363,15 @@ Java_org_apache_hadoop_io_nativeio_NativeIO_00024POSIX_sync_1file_1range(
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CHECK_DIRECT_BUFFER_ADDRESS(buf) \
|
||||||
|
{ \
|
||||||
|
if (!buf) { \
|
||||||
|
THROW(env, "java/lang/UnsupportedOperationException", \
|
||||||
|
"JNI access to direct buffers not available"); \
|
||||||
|
return; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* public static native void mlock_native(
|
* public static native void mlock_native(
|
||||||
* ByteBuffer buffer, long offset);
|
* ByteBuffer buffer, long offset);
|
||||||
|
@ -379,6 +388,7 @@ Java_org_apache_hadoop_io_nativeio_NativeIO_00024POSIX_mlock_1native(
|
||||||
PASS_EXCEPTIONS(env);
|
PASS_EXCEPTIONS(env);
|
||||||
|
|
||||||
if (mlock(buf, len)) {
|
if (mlock(buf, len)) {
|
||||||
|
CHECK_DIRECT_BUFFER_ADDRESS(buf);
|
||||||
throw_ioe(env, errno);
|
throw_ioe(env, errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -399,6 +409,7 @@ Java_org_apache_hadoop_io_nativeio_NativeIO_00024POSIX_munlock_1native(
|
||||||
PASS_EXCEPTIONS(env);
|
PASS_EXCEPTIONS(env);
|
||||||
|
|
||||||
if (munlock(buf, len)) {
|
if (munlock(buf, len)) {
|
||||||
|
CHECK_DIRECT_BUFFER_ADDRESS(buf);
|
||||||
throw_ioe(env, errno);
|
throw_ioe(env, errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -545,9 +545,12 @@ public class TestNativeIO {
|
||||||
bufSum += buf[i];
|
bufSum += buf[i];
|
||||||
}
|
}
|
||||||
FileOutputStream fos = new FileOutputStream(TEST_FILE);
|
FileOutputStream fos = new FileOutputStream(TEST_FILE);
|
||||||
|
try {
|
||||||
fos.write(buf);
|
fos.write(buf);
|
||||||
fos.getChannel().force(true);
|
fos.getChannel().force(true);
|
||||||
|
} finally {
|
||||||
fos.close();
|
fos.close();
|
||||||
|
}
|
||||||
|
|
||||||
FileInputStream fis = null;
|
FileInputStream fis = null;
|
||||||
FileChannel channel = null;
|
FileChannel channel = null;
|
||||||
|
|
|
@ -42,3 +42,5 @@ HDFS-4949 (Unreleased)
|
||||||
|
|
||||||
HDFS-5198. NameNodeRpcServer must not send back DNA_FINALIZE in reply to a
|
HDFS-5198. NameNodeRpcServer must not send back DNA_FINALIZE in reply to a
|
||||||
cache report. (Contributed by Colin Patrick McCabe)
|
cache report. (Contributed by Colin Patrick McCabe)
|
||||||
|
|
||||||
|
HDFS-5195. Prevent passing null pointer to mlock and munlock. (cnauroth)
|
||||||
|
|
Loading…
Reference in New Issue