Skip to content

Commit

Permalink
Unify error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
qpernil committed Aug 28, 2024
1 parent f2aa63e commit 919118c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/yubihsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ yh_rc yh_send_plain_msg(yh_connector *connector, yh_cmd cmd,
Msg response_msg = {0};

if (data_len > sizeof(msg.st.data)) {
DBG_ERR("Tried to transfer oversized data (%zu > %zu)", data_len,
DBG_ERR("%s (%zu > %zu)", yh_strerror(YHR_BUFFER_TOO_SMALL), data_len,
sizeof(msg.st.data));
return YHR_INVALID_PARAMETERS;
return YHR_BUFFER_TOO_SMALL;
}

msg.st.cmd = cmd;
Expand Down Expand Up @@ -431,7 +431,7 @@ static yh_rc send_encrypted_msg(Scp_ctx *session, yh_cmd cmd,

// Outer command { cmd | cmd_len | sid | encrypted payload | mac }
if (3 + 1 + len + SCP_MAC_LEN > SCP_MSG_BUF_SIZE) {
DBG_ERR("%s: %u", yh_strerror(YHR_BUFFER_TOO_SMALL), 3 + 1 + len + SCP_MAC_LEN);
DBG_ERR("%s (%u > %u)", yh_strerror(YHR_BUFFER_TOO_SMALL), 3 + 1 + len + SCP_MAC_LEN, SCP_MSG_BUF_SIZE);
return YHR_BUFFER_TOO_SMALL;
}

Expand Down

0 comments on commit 919118c

Please sign in to comment.