diff --git a/gck-rpc-dispatch.c b/gck-rpc-dispatch.c
index 3f20fc1cf4885cd4195282011f288f389e55e801..184fa41f040e8b99a755033a6652f2690c7b83fc 100644
--- a/gck-rpc-dispatch.c
+++ b/gck-rpc-dispatch.c
@@ -257,8 +257,12 @@ proto_read_byte_array(CallState * cs, CK_BYTE_PTR * array, CK_ULONG * n_array)
 		return PARSE_ERROR;
 
 	if (!valid) {
+		/* No array, no data, just length */
+		if (!egg_buffer_get_uint32
+		    (&msg->buffer, msg->parsed, &msg->parsed, &n_data))
+			return PARSE_ERROR;
+		*n_array = n_data;
 		*array = NULL;
-		*n_array = 0;
 		return CKR_OK;
 	}