Skip to content

Commit 0d7ef87

Browse files
julek-wolfssldgarske
authored andcommitted
Fix bounds check in session deserialization
F-717
1 parent b5c5327 commit 0d7ef87

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/ssl_sess.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2930,24 +2930,33 @@ WOLFSSL_SESSION* wolfSSL_d2i_SSL_SESSION(WOLFSSL_SESSION** sess,
29302930
#endif
29312931
#if defined(HAVE_SESSION_TICKET) || !defined(NO_PSK)
29322932
#ifdef WOLFSSL_TLS13
2933-
if (i - idx < (OPAQUE32_LEN * 2)) {
2933+
2934+
#ifdef WOLFSSL_32BIT_MILLI_TIME
2935+
if (i - idx < OPAQUE32_LEN) {
29342936
ret = BUFFER_ERROR;
29352937
goto end;
29362938
}
2937-
#ifdef WOLFSSL_32BIT_MILLI_TIME
29382939
ato32(data + idx, &s->ticketSeen);
29392940
idx += OPAQUE32_LEN;
29402941
#else
2942+
if (i - idx < (OPAQUE32_LEN * 2)) {
2943+
ret = BUFFER_ERROR;
2944+
goto end;
2945+
}
29412946
{
29422947
word32 seenHi, seenLo;
2943-
29442948
ato32(data + idx, &seenHi);
29452949
idx += OPAQUE32_LEN;
29462950
ato32(data + idx, &seenLo);
29472951
idx += OPAQUE32_LEN;
29482952
s->ticketSeen = ((sword64)seenHi << 32) + seenLo;
29492953
}
29502954
#endif
2955+
2956+
if (i - idx < OPAQUE32_LEN) {
2957+
ret = BUFFER_ERROR;
2958+
goto end;
2959+
}
29512960
ato32(data + idx, &s->ticketAdd);
29522961
idx += OPAQUE32_LEN;
29532962
if (i - idx < OPAQUE8_LEN) {

0 commit comments

Comments
 (0)