changeset 16735:73b1a1971a76

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 da1901d79073
children f1e17f49191a
files jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c	Thu Apr 04 15:39:17 2013 -0700
+++ b/jdk/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));