#define IN_BYTE_BUFFER(arr, len) \
if (len == NULL) \
{ _ret = CKR_ARGUMENTS_BAD; goto _cleanup; } \
- if (!p11_rpc_message_write_byte_buffer (&_msg, arr ? *len : 0)) \
+ if (!p11_rpc_message_write_byte_buffer (&_msg, arr, len)) \
{ _ret = CKR_HOST_MEMORY; goto _cleanup; }
#define IN_BYTE_ARRAY(arr, len) \
bool
p11_rpc_message_write_byte_buffer (p11_rpc_message *msg,
- CK_ULONG count)
+ CK_BYTE_PTR array,
+ CK_ULONG_PTR n_array)
{
assert (msg != NULL);
assert (msg->output != NULL);
/* Make sure this is in the right order */
assert (!msg->signature || p11_rpc_message_verify_part (msg, "fy"));
- p11_rpc_buffer_add_uint32 (msg->output, count);
+ p11_rpc_buffer_add_byte (msg->output, array ? 0 : 1);
+ p11_rpc_buffer_add_uint32 (msg->output, *n_array);
return !p11_buffer_failed (msg->output);
}
CK_ULONG length);
bool p11_rpc_message_write_byte_buffer (p11_rpc_message *msg,
- CK_ULONG count);
+ CK_BYTE_PTR array,
+ CK_ULONG_PTR n_array);
bool p11_rpc_message_write_byte_array (p11_rpc_message *msg,
CK_BYTE_PTR arr,
CK_ULONG *n_buffer)
{
uint32_t length;
+ uint8_t buffer_is_null;
assert (msg != NULL);
assert (buffer != NULL);
/* Check that we're supposed to be reading this at this point */
assert (!msg->signature || p11_rpc_message_verify_part (msg, "fy"));
+ if (!p11_rpc_buffer_get_byte (msg->input, &msg->parsed, &buffer_is_null))
+ return PARSE_ERROR;
/* The number of ulongs there's room for on the other end */
if (!p11_rpc_buffer_get_uint32 (msg->input, &msg->parsed, &length))
return PARSE_ERROR;
*n_buffer = length;
*buffer = NULL;
- /* If set to zero, then they just want the length */
- if (length == 0)
+ /* If buffer is NULL, the caller just wants the length */
+ if (buffer_is_null)
return CKR_OK;
*buffer = p11_rpc_message_alloc_extra (msg, length * sizeof (CK_BYTE));