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 Jul 24, 2023
1 parent ba830a3 commit 387a5b8
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 @@ -431,6 +431,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 @@ -446,11 +447,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 387a5b8

Please sign in to comment.