components/trousers/patches/tspi_rpc_hosttable.c.patch
author Tsu-Phong Wu <Tsu-Phong.Wu@oracle.COM>
Sat, 20 Oct 2012 00:06:08 -0700
branchs11-sru
changeset 2391 811524a2620b
parent 259 components/trousers/patches/hosttable.c.patch@520697a05dde
child 5941 db8aa9865e9f
permissions -rw-r--r--
7123028 Problem with crypto/tss 7041927 tcsd and libtspi should not use TCP/IP sockets 7002966 libtspi can segv in .fini section 6896514 tss code doesn't do correct privilege check when using mlock 7162897 tcsd daemon goes into maintenance mode after reboot

--- src/tspi/rpc/hosttable.c	2010-05-01 19:39:11.000000000 -0700
+++ src/tspi/rpc/hosttable.c	2012-03-23 16:21:30.018582000 -0700
@@ -22,7 +22,7 @@
 struct host_table *ht = NULL;
 
 TSS_RESULT
-host_table_init()
+static host_table_init(void)
 {
 	ht = calloc(1, sizeof(struct host_table));
 	if (ht == NULL) {
@@ -36,8 +36,7 @@
 }
 
 #ifdef SOLARIS
-#pragma init(_init)
-void _init(void)
+static void my_init(void)
 #else
 void __attribute__ ((constructor)) my_init(void)
 #endif
@@ -46,11 +45,14 @@
 	__tspi_obj_list_init();
 }
 
-void
+static void
 host_table_final()
 {
 	struct host_table_entry *hte, *next = NULL;
 
+	if (ht == NULL) /* no host table to free */
+		return;
+
 	MUTEX_LOCK(ht->lock);
 
 	for (hte = ht->entries; hte; hte = next) {
@@ -70,8 +72,7 @@
 }
 
 #ifdef SOLARIS
-#pragma fini(_fini)
-void _fini(void)
+static void my_fini(void)
 #else
 void __attribute__ ((destructor)) my_fini(void)
 #endif
@@ -79,6 +80,11 @@
 	host_table_final();
 }
 
+#ifdef SOLARIS
+#pragma init(my_init)
+#pragma fini(my_fini)
+#endif
+
 TSS_RESULT
 __tspi_add_table_entry(TSS_HCONTEXT tspContext, BYTE *host, int type, struct host_table_entry **ret)
 {