Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup cookie #198

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Odd: I would have expected a warning because of the cast from size_t to int. Maybe the compiler is smarter than I gave it credit for.

Otherwise: LGTM

}

static int
Expand Down
Loading