From 557f19db0b43e4ad0543c5f463765f1c6fc5fb55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moise=CC=81s=20Guimara=CC=83es?= Date: Tue, 7 Oct 2014 13:02:59 -0300 Subject: [PATCH] Adds support to session IDs of size 1 to 31 bytes. Only session IDs of size 0 or 32 bytes was allowed before, now the session ID size may be from 0 to 32 bytes. A size of zero bytes means that is no session ID provided by the server. --- src/internal.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/internal.c b/src/internal.c index f091447ce..df4aeb9bb 100644 --- a/src/internal.c +++ b/src/internal.c @@ -1806,7 +1806,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) /* arrays */ ssl->arrays = (Arrays*)XMALLOC(sizeof(Arrays), ssl->heap, - DYNAMIC_TYPE_ARRAYS); + DYNAMIC_TYPE_ARRAYS); if (ssl->arrays == NULL) { CYASSL_MSG("Arrays Memory error"); return MEMORY_E; @@ -9079,18 +9079,19 @@ static void PickHashSigAlgo(CYASSL* ssl, /* session id */ b = input[i++]; - if (b == ID_LEN) { - if ((i - begin) + ID_LEN > helloSz) - return BUFFER_ERROR; - - XMEMCPY(ssl->arrays->sessionID, input + i, min(b, ID_LEN)); - i += ID_LEN; - ssl->options.haveSessionId = 1; + if (b > ID_LEN) { + CYASSL_MSG("Invalid session ID size"); + return BUFFER_ERROR; } else if (b) { - CYASSL_MSG("Invalid session ID size"); - return BUFFER_ERROR; /* session ID nor 0 neither 32 bytes long */ + if ((i - begin) + b > helloSz) + return BUFFER_ERROR; + + XMEMCPY(ssl->arrays->sessionID, input + i, b); + i += b; + ssl->options.haveSessionId = 1; } + /* suite and compression */ if ((i - begin) + OPAQUE16_LEN + OPAQUE8_LEN > helloSz)