diff options
-rw-r--r-- | trust/module.c | 5 | ||||
-rw-r--r-- | trust/tests/test-module.c | 18 |
2 files changed, 22 insertions, 1 deletions
diff --git a/trust/module.c b/trust/module.c index 15a4890..ba41884 100644 --- a/trust/module.c +++ b/trust/module.c @@ -389,6 +389,8 @@ sys_C_Finalize (CK_VOID_PTR reserved) static CK_RV sys_C_Initialize (CK_VOID_PTR init_args) { + static CK_C_INITIALIZE_ARGS def_args = + { NULL, NULL, NULL, NULL, CKF_OS_LOCKING_OK, NULL, }; CK_C_INITIALIZE_ARGS *args = NULL; int supplied_ok; CK_RV rv; @@ -403,8 +405,9 @@ sys_C_Initialize (CK_VOID_PTR init_args) rv = CKR_OK; - /* pReserved must be NULL */ args = init_args; + if (args == NULL) + args = &def_args; /* ALL supplied function pointers need to have the value either NULL or non-NULL. */ supplied_ok = (args->CreateMutex == NULL && args->DestroyMutex == NULL && diff --git a/trust/tests/test-module.c b/trust/tests/test-module.c index 7f0b1a5..472263a 100644 --- a/trust/tests/test-module.c +++ b/trust/tests/test-module.c @@ -144,6 +144,23 @@ test_get_slot_list (CuTest *cu) } static void +test_null_initialize (CuTest *cu) +{ + CK_FUNCTION_LIST *module; + CK_RV rv; + + /* This is the entry point of the trust module, linked to this test */ + rv = C_GetFunctionList (&module); + CuAssertTrue (cu, rv == CKR_OK); + + rv = module->C_Initialize (NULL); + CuAssertTrue (cu, rv == CKR_OK); + + rv = module->C_Finalize (NULL); + CuAssertIntEquals (cu, CKR_OK, rv); +} + +static void test_multi_initialize (CuTest *cu) { static CK_C_INITIALIZE_ARGS args = @@ -1057,6 +1074,7 @@ main (void) putenv ("P11_KIT_STRICT=1"); p11_library_init (); + SUITE_ADD_TEST (suite, test_null_initialize); SUITE_ADD_TEST (suite, test_multi_initialize); SUITE_ADD_TEST (suite, test_get_slot_list); SUITE_ADD_TEST (suite, test_get_slot_info); |