Skip to content

Commit f5c93a4

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

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
@@ -416,6 +416,7 @@ dtls_write(struct dtls_context_t *ctx, session_t *session,
416416

417417
static int
418418
dtls_get_cookie(uint8 *msg, size_t msglen, uint8 **cookie) {
419+
size_t cookie_len;
419420
/* To access the cookie, we have to determine the session id's
420421
* length and skip the whole thing. */
421422
if (msglen < DTLS_HS_LENGTH + DTLS_CH_LENGTH + sizeof(uint8))
@@ -431,11 +432,11 @@ dtls_get_cookie(uint8 *msg, size_t msglen, uint8 **cookie) {
431432
SKIP_VAR_FIELD(msg, msglen, uint8, DTLS_ALERT_HANDSHAKE_FAILURE,
432433
"get_cookie, session_id");
433434

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

437-
*cookie = msg + sizeof(uint8);
438-
return dtls_uint8_to_int(msg);
438+
*cookie = msg;
439+
return cookie_len;
439440
}
440441

441442
static int

0 commit comments

Comments
 (0)