h2_push.c 31.7 KB
Newer Older
powelld's avatar
powelld committed

    decoder.diary    = diary;
    decoder.pool     = pool;
    decoder.log2p    = log2p;
    decoder.data     = (const unsigned char*)data;
    decoder.datalen  = len;
    decoder.offset   = 1;
    decoder.bit      = 8;
    decoder.last_val = 0;
    
    diary->N = N;
    /* Determine effective N we use for storage */
    if (!N) {
        /* a totally empty cache digest. someone tells us that she has no
         * entries in the cache at all. Use our own preferences for N+mask 
         */
        diary->N = diary->NMax;
        return APR_SUCCESS;
    }
    else if (N > diary->NMax) {
        /* Store not more than diary is configured to hold. We open us up
         * to DOS attacks otherwise. */
        diary->N = diary->NMax;
    }
    
    /* Intentional no APLOGNO */
    ap_log_perror(APLOG_MARK, GCSLOG_LEVEL, 0, pool,
                  "h2_push_diary_digest_set: N=%d, log2n=%d, "
                  "diary->mask_bits=%d, dec.log2p=%d", 
                  (int)diary->N, (int)log2n, diary->mask_bits, 
                  (int)decoder.log2p);
                  
    for (i = 0; i < diary->N; ++i) {
        if (gset_decode_next(&decoder, &e.hash) != APR_SUCCESS) {
            /* the data may have less than N values */
            break;
        }
        h2_push_diary_append(diary, &e);
    }
    
    /* Intentional no APLOGNO */
    ap_log_perror(APLOG_MARK, GCSLOG_LEVEL, 0, pool,
                  "h2_push_diary_digest_set: diary now with %d entries, mask_bits=%d", 
                  (int)diary->entries->nelts, diary->mask_bits);
    return status;
}

apr_status_t h2_push_diary_digest64_set(h2_push_diary *diary, const char *authority, 
                                        const char *data64url, apr_pool_t *pool)
{
    const char *data;
    apr_size_t len = h2_util_base64url_decode(&data, data64url, pool);
    /* Intentional no APLOGNO */
    ap_log_perror(APLOG_MARK, GCSLOG_LEVEL, 0, pool,
                  "h2_push_diary_digest64_set: digest=%s, dlen=%d", 
                  data64url, (int)len);
    return h2_push_diary_digest_set(diary, authority, data, len);
}