Mercurial > hg > openjdk > jigsaw > jdk
changeset 7242:7d4e30730f80
7155720: PKCS11 minor issues in native code
Summary: Added OOM handling to address the two issues found by parfait.
Reviewed-by: weijun
author | valeriep |
---|---|
date | Thu, 04 Apr 2013 20:05:47 -0700 |
parents | 7b1189bf1d7b |
children | b62a76763bf3 |
files | src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c Thu Apr 04 15:39:17 2013 -0700 +++ b/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c Thu Apr 04 20:05:47 2013 -0700 @@ -1,5 +1,5 @@ /* - * 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 @@ 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 @@ * 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));