Skip to content

Commit 387a5b8

Browse files
committed
dtls.c: use GET_VAR_FIELD in dtls_get_cookie.
Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
1 parent ba830a3 commit 387a5b8

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

dtls.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ dtls_write(struct dtls_context_t *ctx, session_t *session,
431431

432432
static int
433433
dtls_get_cookie(uint8 *msg, size_t msglen, uint8 **cookie) {
434+
size_t cookie_len;
434435
/* To access the cookie, we have to determine the session id's
435436
* length and skip the whole thing. */
436437
if (msglen < DTLS_HS_LENGTH + DTLS_CH_LENGTH + sizeof(uint8))
@@ -446,11 +447,11 @@ dtls_get_cookie(uint8 *msg, size_t msglen, uint8 **cookie) {
446447
SKIP_VAR_FIELD(msg, msglen, uint8, DTLS_ALERT_HANDSHAKE_FAILURE,
447448
"get_cookie, session_id");
448449

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

452-
*cookie = msg + sizeof(uint8);
453-
return dtls_uint8_to_int(msg);
453+
*cookie = msg;
454+
return cookie_len;
454455
}
455456

456457
static int

0 commit comments

Comments
 (0)