提交 c24c6f91 编写于 作者: A alanb

6787009: (attach) Stub injection potentially unsafe on windows-x64

Reviewed-by: mchung
上级 fd0f7831
...@@ -345,7 +345,6 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_WindowsVirtualMachine_enqueue ...@@ -345,7 +345,6 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_WindowsVirtualMachine_enqueue
DataBlock data; DataBlock data;
DataBlock* pData; DataBlock* pData;
DWORD* pCode; DWORD* pCode;
DWORD numBytes;
DWORD stubLen; DWORD stubLen;
HANDLE hProcess, hThread; HANDLE hProcess, hThread;
jint argsLen, i; jint argsLen, i;
...@@ -400,7 +399,7 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_WindowsVirtualMachine_enqueue ...@@ -400,7 +399,7 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_WindowsVirtualMachine_enqueue
JNU_ThrowIOExceptionWithLastError(env, "VirtualAllocEx failed"); JNU_ThrowIOExceptionWithLastError(env, "VirtualAllocEx failed");
return; return;
} }
WriteProcessMemory( hProcess, (LPVOID)pData, (LPVOID)&data, (DWORD)sizeof(DataBlock), &numBytes ); WriteProcessMemory( hProcess, (LPVOID)pData, (LPCVOID)&data, (SIZE_T)sizeof(DataBlock), NULL );
stubLen = (DWORD)(*env)->GetArrayLength(env, stub); stubLen = (DWORD)(*env)->GetArrayLength(env, stub);
...@@ -412,7 +411,7 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_WindowsVirtualMachine_enqueue ...@@ -412,7 +411,7 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_WindowsVirtualMachine_enqueue
VirtualFreeEx(hProcess, pData, 0, MEM_RELEASE); VirtualFreeEx(hProcess, pData, 0, MEM_RELEASE);
return; return;
} }
WriteProcessMemory( hProcess, (LPVOID)pCode, (LPVOID)stubCode, (DWORD)stubLen, &numBytes ); WriteProcessMemory( hProcess, (LPVOID)pCode, (LPCVOID)stubCode, (SIZE_T)stubLen, NULL );
if (isCopy) { if (isCopy) {
(*env)->ReleaseByteArrayElements(env, stub, stubCode, JNI_ABORT); (*env)->ReleaseByteArrayElements(env, stub, stubCode, JNI_ABORT);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册