From 603f1fa2d2006110f9e15dcb0762947e6a2c9391 Mon Sep 17 00:00:00 2001
From: Fredrik Thulin <fredrik@thulin.net>
Date: Mon, 21 Jan 2013 13:59:10 +0100
Subject: [PATCH] Remove deprecated code to pass NULL strings.

Code to pass NULL strings was only used in C_InitToken, but since
the argument there was really space padded and not NULL terminated,
this code is no longer needed.
---
 gck-rpc-dispatch.c | 33 ---------------------------------
 gck-rpc-message.c  | 10 ----------
 gck-rpc-module.c   |  4 ----
 gck-rpc-private.h  |  4 ----
 4 files changed, 51 deletions(-)

diff --git a/gck-rpc-dispatch.c b/gck-rpc-dispatch.c
index be1d7d9..a6f7634 100644
--- a/gck-rpc-dispatch.c
+++ b/gck-rpc-dispatch.c
@@ -572,35 +572,6 @@ proto_write_attribute_array(CallState * cs, CK_ATTRIBUTE_PTR array,
 	return CKR_OK;
 }
 
-static CK_RV proto_read_null_string(CallState * cs, CK_UTF8CHAR_PTR * val)
-{
-	GckRpcMessage *msg;
-	const unsigned char *data;
-	size_t n_data;
-
-	assert(cs);
-	assert(val);
-
-	msg = cs->req;
-
-	/* Check that we're supposed to have this at this point */
-	assert(!msg->signature || gck_rpc_message_verify_part(msg, "z"));
-
-	if (!egg_buffer_get_byte_array
-	    (&msg->buffer, msg->parsed, &msg->parsed, &data, &n_data))
-		return PARSE_ERROR;
-
-	/* Allocate a block of memory for it. The +1 accomodates the NULL byte. */
-	*val = call_alloc(cs, n_data + 1);
-	if (!*val)
-		return CKR_DEVICE_MEMORY;
-
-	memcpy(*val, data, n_data);
-	(*val)[n_data] = 0;
-
-	return CKR_OK;
-}
-
 static CK_RV proto_read_space_string(CallState * cs, CK_UTF8CHAR_PTR * val, CK_ULONG length)
 {
 	GckRpcMessage *msg;
@@ -805,10 +776,6 @@ static CK_RV proto_write_session_info(CallState * cs, CK_SESSION_INFO_PTR info)
 	if (!gck_rpc_message_read_ulong (cs->req, &val)) \
 		{ _ret = PARSE_ERROR; goto _cleanup; }
 
-#define IN_STRING(val) \
-	_ret = proto_read_null_string (cs, &val); \
-	if (_ret != CKR_OK) goto _cleanup;
-
 #define IN_SPACE_STRING(val, len)			   \
 	_ret = proto_read_space_string (cs, &val, len);	   \
 	if (_ret != CKR_OK) goto _cleanup;
diff --git a/gck-rpc-message.c b/gck-rpc-message.c
index 440d88d..a99ecdf 100644
--- a/gck-rpc-message.c
+++ b/gck-rpc-message.c
@@ -477,13 +477,3 @@ gck_rpc_message_write_space_string(GckRpcMessage * msg, CK_UTF8CHAR * buffer,
 
 	return egg_buffer_add_byte_array(&msg->buffer, buffer, length);
 }
-
-int gck_rpc_message_write_zero_string(GckRpcMessage * msg, CK_UTF8CHAR * string)
-{
-	assert(msg);
-	assert(string);
-
-	assert(!msg->signature || gck_rpc_message_verify_part(msg, "z"));
-
-	return egg_buffer_add_string(&msg->buffer, (const char *)string);
-}
diff --git a/gck-rpc-module.c b/gck-rpc-module.c
index c3b62c1..1ce0665 100644
--- a/gck-rpc-module.c
+++ b/gck-rpc-module.c
@@ -1130,10 +1130,6 @@ proto_read_sesssion_info(GckRpcMessage * msg, CK_SESSION_INFO_PTR info)
 	if (!gck_rpc_message_write_ulong (_cs->req, val)) \
 		{ _ret = CKR_HOST_MEMORY; goto _cleanup; }
 
-#define IN_STRING(val) \
-	if (!gck_rpc_message_write_zero_string (_cs->req, val)) \
-		{ _ret = CKR_HOST_MEMORY; goto _cleanup; }
-
 #define IN_SPACE_STRING(val, len)						\
 	if (!gck_rpc_message_write_space_string (_cs->req, val, len))	\
 		{ _ret = CKR_HOST_MEMORY; goto _cleanup; }
diff --git a/gck-rpc-private.h b/gck-rpc-private.h
index a3843e5..f888c41 100644
--- a/gck-rpc-private.h
+++ b/gck-rpc-private.h
@@ -130,7 +130,6 @@ typedef struct _GckRpcCall {
  *  s  = space padded string
  *  v  = CK_VERSION
  *  y  = CK_BYTE
- *  z  = null terminated string
  */
 
 static const GckRpcCall gck_rpc_calls[] = {
@@ -263,9 +262,6 @@ int gck_rpc_message_write_byte(GckRpcMessage * msg, CK_BYTE val);
 
 int gck_rpc_message_write_ulong(GckRpcMessage * msg, CK_ULONG val);
 
-int gck_rpc_message_write_zero_string(GckRpcMessage * msg,
-				      CK_UTF8CHAR * string);
-
 int gck_rpc_message_write_space_string(GckRpcMessage * msg,
 				       CK_UTF8CHAR * buffer, CK_ULONG length);
 
-- 
GitLab