Skip to content

Commit

Permalink
Fix division by zero in proto_read_attribute_buffer_array
Browse files Browse the repository at this point in the history
Signed-off-by: Zoltan Fridrich <[email protected]>
  • Loading branch information
ZoltanFridrich committed Mar 21, 2024
1 parent 1195177 commit d3938b7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions p11-kit/rpc-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ proto_read_attribute_buffer_array (p11_rpc_message *msg,
rv = proto_read_attribute_buffer_array (msg, &array, &n_array);
if (rv != CKR_OK)
return rv;
if (ULONG_MAX / n_array < sizeof (CK_ATTRIBUTE) ||
if ((n_array != 0 && ULONG_MAX / n_array < sizeof (CK_ATTRIBUTE)) ||
length < n_array * sizeof (CK_ATTRIBUTE))
return PARSE_ERROR;
attrs[i].pValue = array;
attrs[i].pValue = (n_array == 0) ? NULL : array;
attrs[i].ulValueLen = n_array * sizeof (CK_ATTRIBUTE);
} else {
attrs[i].pValue = p11_rpc_message_alloc_extra (msg, length);
Expand Down

0 comments on commit d3938b7

Please sign in to comment.