]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Don't copy the VPs when we can just move them
authorAlan T. DeKok <aland@freeradius.org>
Tue, 16 Jun 2015 14:23:28 +0000 (10:23 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 16 Jun 2015 14:23:28 +0000 (10:23 -0400)
src/main/tls.c

index 1936bf56ac8829df292865af1f4741748e4f8988..260b7e45445f69e0f1b9c59ec9701ddae4fa30e1 100644 (file)
@@ -1257,12 +1257,12 @@ static SSL_SESSION *cbtls_get_session(SSL *ssl, unsigned char *data, int len, in
                char            filename[256];
                unsigned char   *p;
                struct stat     st;
-               VALUE_PAIR      *vp;
+               VALUE_PAIR      *vps = NULL;
 
                /* read in the cached VPs from the .vps file */
                snprintf(filename, sizeof(filename), "%s%c%s.vps",
                         conf->session_cache_path, FR_DIR_SEP, buffer);
-               rv = pairlist_read(NULL, filename, &pairlist, 1);
+               rv = pairlist_read(talloc_ctx, filename, &pairlist, 1);
                if (rv < 0) {
                        /* not safe to un-persist a session w/o VPs */
                        RWDEBUG("Failed loading persisted VPs for session %s", buffer);
@@ -1314,9 +1314,9 @@ static SSL_SESSION *cbtls_get_session(SSL *ssl, unsigned char *data, int len, in
                        goto err;
                }
 
-               /* cache the VPs into the session */
-               vp = paircopy(talloc_ctx, pairlist->reply);
-               SSL_SESSION_set_ex_data(sess, fr_tls_ex_index_vps, vp);
+               /* move the cached VPs into the session */
+               pairfilter(talloc_ctx, &vps, &pairlist->reply, 0, 0, TAG_ANY);
+               SSL_SESSION_set_ex_data(sess, fr_tls_ex_index_vps, vps);
                RWDEBUG("Successfully restored session %s", buffer);
        }
 err: