This fixes an infinite loop that occurs when tests are run and
PKCS11_USER_PIN isn't set.

Singed-off-by Fionnuala Gunter [email protected]
>From bfddb252df6338df83528aebcfbf138ba3da06dd Mon Sep 17 00:00:00 2001
From: Fionnuala Gunter <[email protected]>
Date: Tue, 9 Aug 2011 12:35:49 -0500
Subject: [PATCH] fixed infinite loop that occured when PKCS11_USER_PIN wasn't set

---
 testcases/include/regress.h |   35 +++++++++++++++++++++--------------
 1 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/testcases/include/regress.h b/testcases/include/regress.h
index 27d3e42..591750b 100755
--- a/testcases/include/regress.h
+++ b/testcases/include/regress.h
@@ -173,12 +173,16 @@ int get_user_pin(CK_BYTE_PTR);
         } while (0)
 
 #define testcase_notice(_fmt, ...)                                      \
-        printf("* TESTCASE %s NOTICE " _fmt "\n",                       \
-                __func__, ## __VA_ARGS__)
+	do {								\
+        	printf("* TESTCASE %s NOTICE " _fmt "\n",               \
+                	__func__, ## __VA_ARGS__);			\
+	} while (0)
 
 #define testcase_notice_f(_func, _fmt, ...)                             \
-        printf("* TESTCASE %s NOTICE " _fmt "\n",                       \
-                _func, ## __VA_ARGS__)
+	do {								\
+        	printf("* TESTCASE %s NOTICE " _fmt "\n",               \
+                	_func, ## __VA_ARGS__);				\
+	} while (0)
 
 #define testcase_fail(_fmt, ...)                                        \
         do {                                                            \
@@ -213,8 +217,10 @@ int get_user_pin(CK_BYTE_PTR);
 	} while (0)
 
 #define testcase_print_result()						\
-	printf("Total=%lu, Ran=%lu, Passed=%lu, Failed=%lu, Skipped=%lu, Errors=%lu\n", \
-			(t_ran + t_skipped), t_ran, t_passed, t_failed, t_skipped, t_errors);
+	do {								\
+		printf("Total=%lu, Ran=%lu, Passed=%lu, Failed=%lu, Skipped=%lu, Errors=%lu\n", \
+			(t_ran + t_skipped), t_ran, t_passed, t_failed, t_skipped, t_errors);	\
+	} while (0)
 
 #define testcase_rw_session()                                           \
         do {                                                            \
@@ -267,8 +273,8 @@ int get_user_pin(CK_BYTE_PTR);
         do {                                                            \
                 if (get_user_pin(user_pin)) {                           \
                         testcase_error("get_user_pin() failed");        \
-                        rc = -1;                                        \
-                        goto testcase_cleanup;                          \
+                        testcase_closeall_session();			\
+			exit(-1);		                        \
                 }                                                       \
                 user_pin_len = (CK_ULONG) strlen( (char *) user_pin);   \
                 rc = funcs->C_Login(session, CKU_USER,                  \
@@ -281,13 +287,14 @@ int get_user_pin(CK_BYTE_PTR);
         } while (0)
 
 #define testcase_user_logout()                                          \
-        rc = funcs->C_Logout(session);                                  \
-        if (rc != CKR_OK) {                                             \
-                testcase_error("C_Logout() rc = %s",                    \
+	do {								\
+        	rc = funcs->C_Logout(session);                          \
+        	if (rc != CKR_OK) {                                     \
+                	testcase_error("C_Logout() rc = %s",            \
                                 p11_get_ckr(rc));                       \
-                goto testcase_cleanup;                                  \
-        }                                                               \
-                                                                        \
+                	goto testcase_cleanup;                          \
+        	}                                                       \
+        } while (0)   					                
 
 
 #define testcase_so_login()                                             \
-- 
1.7.1

------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Opencryptoki-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opencryptoki-tech

Reply via email to