/* Write the number of items */
p11_rpc_buffer_add_uint32 (msg->output, num);
+ /* Is arr not null ? */
+ p11_rpc_buffer_add_byte (msg->output, arr ? 0 : 1);
+
for (i = 0; i < num; ++i) {
attr = &(arr[i]);
/* The attribute type */
p11_rpc_buffer_add_uint32 (msg->output, attr->type);
+ /* rpc_server.c:value_is_null, is the value buffer not NULL ? */
+ p11_rpc_buffer_add_byte (msg->output, attr->pValue ? 0 : 1);
+
/* And the attribute buffer length */
- p11_rpc_buffer_add_uint32 (msg->output, attr->pValue ? attr->ulValueLen : 0);
+ p11_rpc_buffer_add_uint32 (msg->output, attr->ulValueLen);
}
return !p11_buffer_failed (msg->output);
{
CK_ATTRIBUTE_PTR attrs;
uint32_t n_attrs, i;
+ uint8_t attrs_is_null;
uint32_t value;
assert (msg != NULL);
if (!p11_rpc_buffer_get_uint32 (msg->input, &msg->parsed, &n_attrs))
return PARSE_ERROR;
+ /* Is attrs pointer null or not ? */
+ if (!p11_rpc_buffer_get_byte (msg->input, &msg->parsed, &attrs_is_null))
+ return PARSE_ERROR;
+
+ if (attrs_is_null) {
+ *result = NULL;
+ *n_result = n_attrs;
+ return CKR_OK;
+ }
+
/* Allocate memory for the attribute structures */
attrs = p11_rpc_message_alloc_extra (msg, n_attrs * sizeof (CK_ATTRIBUTE));
if (attrs == NULL)
/* Now go through and fill in each one */
for (i = 0; i < n_attrs; ++i) {
+ uint8_t value_is_null;
/* The attribute type */
if (!p11_rpc_buffer_get_uint32 (msg->input, &msg->parsed, &value))
attrs[i].type = value;
+ /* Is the value buffer not NULL ? */
+ if (!p11_rpc_buffer_get_byte (msg->input, &msg->parsed, &value_is_null))
+ return PARSE_ERROR;
+
/* The number of bytes to allocate */
if (!p11_rpc_buffer_get_uint32 (msg->input, &msg->parsed, &value))
return PARSE_ERROR;
- if (value == 0) {
+ attrs[i].ulValueLen = value;
+
+ if (value_is_null) {
attrs[i].pValue = NULL;
- attrs[i].ulValueLen = 0;
} else {
attrs[i].pValue = p11_rpc_message_alloc_extra (msg, value);
if (!attrs[i].pValue)
return CKR_DEVICE_MEMORY;
- attrs[i].ulValueLen = value;
}
}