Changeset f450ac9 in mod_gnutls for src/gnutls_hooks.c


Ignore:
Timestamp:
Jun 9, 2016, 2:50:43 PM (4 years ago)
Author:
Thomas Klute <thomas2.klute@…>
Branches:
debian/master, debian/stretch-backports, master, proxy-ticket, upstream
Children:
70a1e5a
Parents:
d18afb8
git-author:
Thomas Klute <thomas2.klute@…> (06/09/16 14:36:10)
git-committer:
Thomas Klute <thomas2.klute@…> (06/09/16 14:50:43)
Message:

Replace mgs_session_id2sz() with apr_(p?)escape_hex()

There's no need to carry a local bin-to-hex function if APR already
provides a converter. Using integrated pool allocation even avoids a
few string copies in gnutls_hooks.c.

The session hex buffers in gnutls_cache.c don't need room for the
memcache tag because it is added in a apr_psprintf() call if
necessary, so we can save a few bytes of stack space there.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_hooks.c

    rd18afb8 rf450ac9  
    2727#include "mod_status.h"
    2828#include <util_mutex.h>
     29#include <apr_escape.h>
    2930
    3031#ifdef ENABLE_MSVA
     
    893894int mgs_hook_fixups(request_rec * r) {
    894895    unsigned char sbuf[GNUTLS_MAX_SESSION_ID];
    895     char buf[AP_IOBUFSIZE];
    896896    const char *tmp;
    897897    size_t len;
     
    963963    len = sizeof (sbuf);
    964964    gnutls_session_get_id(ctxt->session, sbuf, &len);
    965     tmp = mgs_session_id2sz(sbuf, len, buf, sizeof (buf));
    966     apr_table_setn(env, "SSL_SESSION_ID", apr_pstrdup(r->pool, tmp));
     965    apr_table_setn(env, "SSL_SESSION_ID",
     966                   apr_pescape_hex(r->pool, sbuf, len, 0));
    967967
    968968    if (gnutls_certificate_type_get(ctxt->session) == GNUTLS_CRT_X509) {
     
    10991099    len = sizeof (sbuf);
    11001100    gnutls_x509_crt_get_serial(cert, sbuf, &len);
    1101     tmp = mgs_session_id2sz(sbuf, len, buf, sizeof (buf));
    1102     apr_table_setn(env, MGS_SIDE("_M_SERIAL"), apr_pstrdup(r->pool, tmp));
     1101    apr_table_setn(env, MGS_SIDE("_M_SERIAL"),
     1102                   apr_pescape_hex(r->pool, sbuf, len, 0));
    11031103
    11041104    ret = gnutls_x509_crt_get_version(cert);
     
    12161216    len = sizeof (sbuf);
    12171217    gnutls_openpgp_crt_get_fingerprint(cert, sbuf, &len);
    1218     tmp = mgs_session_id2sz(sbuf, len, buf, sizeof (buf));
    1219     apr_table_setn(env, MGS_SIDE("_FINGERPRINT"), apr_pstrdup(r->pool, tmp));
     1218    apr_table_setn(env, MGS_SIDE("_FINGERPRINT"),
     1219                   apr_pescape_hex(r->pool, sbuf, len, 0));
    12201220
    12211221    ret = gnutls_openpgp_crt_get_version(cert);
Note: See TracChangeset for help on using the changeset viewer.