Changeset 2f932fa in mod_gnutls


Ignore:
Timestamp:
Jun 5, 2016, 3:42:32 PM (20 months ago)
Author:
Thomas Klute <thomas2.klute@…>
Branches:
master, debian, upstream
Children:
6b4136c
Parents:
6814e48
git-author:
Thomas Klute <thomas2.klute@…> (06/05/16 07:37:11)
git-committer:
Thomas Klute <thomas2.klute@…> (06/05/16 15:42:32)
Message:

Use gnutls_datum_t to pass DBM keys for GnuTLS sessions

The APR memcached client interface does not use apr_datum_t. This
change makes it easier to keep function signatures identical among the
mod_gnutls cache functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_cache.c

    r6814e48 r2f932fa  
    6969 * to disallow resuming sessions on different servers
    7070 */
    71 static int mgs_session_id2dbm(conn_rec * c, unsigned char *id, int idlen,
    72         apr_datum_t * dbmkey) {
     71static int mgs_session_id2dbm(conn_rec *c, unsigned char *id, int idlen,
     72                              gnutls_datum_t *dbmkey)
     73{
    7374    char buf[STR_SESSION_LEN];
    7475    char *sz;
     
    7879        return -1;
    7980
    80     dbmkey->dptr =
    81             apr_psprintf(c->pool, "%s:%d.%s",
    82             c->base_server->server_hostname,
    83             c->base_server->port, sz);
    84     dbmkey->dsize = strlen(dbmkey->dptr);
    85 
     81    char *newkey = apr_psprintf(c->pool, "%s:%d.%s",
     82                                c->base_server->server_hostname,
     83                                c->base_server->port, sz);
     84    dbmkey->size = strlen(newkey);
     85    /* signedness does not matter for arbitrary bits */
     86    dbmkey->data = (unsigned char*) newkey;
    8687    return 0;
    8788}
     
    394395}
    395396
    396 static gnutls_datum_t dbm_cache_fetch(mgs_handle_t *ctxt, apr_datum_t key)
     397static gnutls_datum_t dbm_cache_fetch(mgs_handle_t *ctxt, gnutls_datum_t key)
    397398{
    398399    gnutls_datum_t data = {NULL, 0};
    399400    apr_dbm_t *dbm;
     401    apr_datum_t dbmkey = {(char*) key.data, key.size};
    400402    apr_datum_t dbmval;
    401403    apr_status_t rv;
     
    411413    }
    412414
    413     rv = apr_dbm_fetch(dbm, key, &dbmval);
     415    rv = apr_dbm_fetch(dbm, dbmkey, &dbmval);
    414416
    415417    if (rv != APR_SUCCESS) {
     
    445447}
    446448
    447 static gnutls_datum_t dbm_cache_fetch_session(void *baton,
    448                                               gnutls_datum_t key)
     449static gnutls_datum_t dbm_cache_fetch_session(void *baton, gnutls_datum_t key)
    449450{
    450451    gnutls_datum_t data = {NULL, 0};
    451     apr_datum_t dbmkey;
     452    gnutls_datum_t dbmkey;
    452453    mgs_handle_t *ctxt = baton;
    453454
     
    458459}
    459460
    460 static int dbm_cache_store(server_rec *s, apr_datum_t key,
     461static int dbm_cache_store(server_rec *s, gnutls_datum_t key,
    461462                           gnutls_datum_t data, apr_time_t expiry)
    462463{
     
    465466
    466467    apr_dbm_t *dbm;
     468    apr_datum_t dbmkey = {(char*) key.data, key.size};
    467469    apr_datum_t dbmval;
    468470    apr_status_t rv;
     
    495497    }
    496498
    497     rv = apr_dbm_store(dbm, key, dbmval);
     499    rv = apr_dbm_store(dbm, dbmkey, dbmval);
    498500    if (rv != APR_SUCCESS)
    499501    {
     
    508510    ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, s,
    509511                 "stored %ld bytes of data (%ld byte key) in cache '%s'",
    510                  dbmval.dsize, key.dsize, sc->cache_config);
     512                 dbmval.dsize, dbmkey.dsize, sc->cache_config);
    511513
    512514    apr_dbm_close(dbm);
     
    521523{
    522524    mgs_handle_t *ctxt = baton;
    523     apr_datum_t dbmkey;
     525    gnutls_datum_t dbmkey;
    524526
    525527    if (mgs_session_id2dbm(ctxt->c, key.data, key.size, &dbmkey) < 0)
     
    533535static int dbm_cache_delete(void *baton, gnutls_datum_t key) {
    534536    apr_dbm_t *dbm;
    535     apr_datum_t dbmkey;
     537    gnutls_datum_t tmpkey;
    536538    mgs_handle_t *ctxt = baton;
    537539    apr_status_t rv;
    538540
    539     if (mgs_session_id2dbm(ctxt->c, key.data, key.size, &dbmkey) < 0)
    540         return -1;
     541    if (mgs_session_id2dbm(ctxt->c, key.data, key.size, &tmpkey) < 0)
     542        return -1;
     543    apr_datum_t dbmkey = {(char*) tmpkey.data, tmpkey.size};
    541544
    542545    rv = apr_dbm_open_ex(&dbm, db_type(ctxt->sc),
Note: See TracChangeset for help on using the changeset viewer.