提交 1cdda8ec 编写于 作者: V valeriep

7155720: PKCS11 minor issues in native code

Summary: Added OOM handling to address the two issues found by parfait.
Reviewed-by: weijun
上级 2527eef0
/*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
......@@ -104,6 +104,10 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_connect
if (hModule == NULL) {
systemErrorMessage = dlerror();
exceptionMessage = (char *) malloc(sizeof(char) * (strlen(systemErrorMessage) + strlen(libraryNameStr) + 1));
if (exceptionMessage == NULL) {
throwOutOfMemoryError(env, 0);
return;
}
strcpy(exceptionMessage, systemErrorMessage);
strcat(exceptionMessage, libraryNameStr);
throwIOException(env, exceptionMessage);
......@@ -134,6 +138,11 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_connect
* Get function pointers to all PKCS #11 functions
*/
moduleData = (ModuleData *) malloc(sizeof(ModuleData));
if (moduleData == NULL) {
dlclose(hModule);
throwOutOfMemoryError(env, 0);
return;
}
moduleData->hModule = hModule;
moduleData->applicationMutexHandler = NULL;
rv = (C_GetFunctionList)(&(moduleData->ckFunctionListPtr));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册