Skip to content

Commit

Permalink
dtls.c: use GET_VAR_FIELD in dtls_get_cookie.
Browse files Browse the repository at this point in the history
Signed-off-by: Achim Kraus <[email protected]>
  • Loading branch information
boaks committed Jun 2, 2024
1 parent 9d6cf54 commit e78da6b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ dtls_write(struct dtls_context_t *ctx, session_t *session,

static int
dtls_get_cookie(uint8 *msg, size_t msglen, uint8 **cookie) {
size_t cookie_len;
/* To access the cookie, we have to determine the session id's
* length and skip the whole thing. */
if (msglen < DTLS_HS_LENGTH + DTLS_CH_LENGTH + sizeof(uint8))
Expand All @@ -452,11 +453,11 @@ dtls_get_cookie(uint8 *msg, size_t msglen, uint8 **cookie) {
SKIP_VAR_FIELD(msg, msglen, uint8, DTLS_ALERT_HANDSHAKE_FAILURE,
"get_cookie, session_id");

if (msglen < (*msg & 0xff) + sizeof(uint8))
return dtls_alert_fatal_create(DTLS_ALERT_HANDSHAKE_FAILURE);
GET_VAR_FIELD(cookie_len, msg, msglen, uint8, DTLS_ALERT_HANDSHAKE_FAILURE,
"get_cookie, cookie");

*cookie = msg + sizeof(uint8);
return dtls_uint8_to_int(msg);
*cookie = msg;
return cookie_len;
}

static int
Expand Down

0 comments on commit e78da6b

Please sign in to comment.