]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Update session_ticket.c to add support for zero length session tickets returned from...
authorrrivers2 <5981058-rrivers2@users.noreply.gitlab.com>
Sun, 24 May 2020 23:11:01 +0000 (23:11 +0000)
committerrrivers2 <5981058-rrivers2@users.noreply.gitlab.com>
Sun, 24 May 2020 23:11:01 +0000 (23:11 +0000)
check that ticket_len > 0 prior to calling gnutls_realloc_fast

Signed-off-by: Rod Rivers <5981058-rrivers2@users.noreply.gitlab.com>
lib/ext/session_ticket.c

index c854d9c2a93a83455359993df1d26e57e5e2ca13..8d4595821a8d9eac73b2889983e2f386cd013fdb 100644 (file)
@@ -787,15 +787,17 @@ int _gnutls_recv_new_session_ticket(gnutls_session_t session)
                ret = GNUTLS_E_MEMORY_ERROR;
                goto error;
        }
-       priv->session_ticket =
-           gnutls_realloc_fast(priv->session_ticket, ticket_len);
-       if (!priv->session_ticket) {
-               gnutls_free(priv);
-               gnutls_assert();
-               ret = GNUTLS_E_MEMORY_ERROR;
-               goto error;
+       if (ticket_len > 0) {
+               priv->session_ticket =
+                   gnutls_realloc_fast(priv->session_ticket, ticket_len);
+               if (!priv->session_ticket) {
+                       gnutls_free(priv);
+                       gnutls_assert();
+                       ret = GNUTLS_E_MEMORY_ERROR;
+                       goto error;
+               }
+               memcpy(priv->session_ticket, p, ticket_len);
        }
-       memcpy(priv->session_ticket, p, ticket_len);
        priv->session_ticket_len = ticket_len;
        epriv = priv;