summaryrefslogtreecommitdiff
path: root/src/mod_auth.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2022-12-10 15:15:33 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2022-12-10 15:15:33 -0500
commit5e14db43b7212b52f1cfcd2b0fce41df7fc419eb (patch)
tree1ae34085634983b89f972101f51785ce4d7ff30b /src/mod_auth.c
parentabf470bebe446db762e01d04e894691390da7d45 (diff)
downloadlighttpd-git-5e14db43b7212b52f1cfcd2b0fce41df7fc419eb.tar.gz
[multiple] employ ck_calloc, ck_malloc shared code
employ ck_calloc(), ck_malloc() shared code to slightly reduce code size (centralize the ck_assert() to check that memory allocation succeeded)
Diffstat (limited to 'src/mod_auth.c')
-rw-r--r--src/mod_auth.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/mod_auth.c b/src/mod_auth.c
index 57dd87a5..70629518 100644
--- a/src/mod_auth.c
+++ b/src/mod_auth.c
@@ -65,9 +65,8 @@ http_auth_cache_entry_init (const struct http_auth_require_t * const require, co
*(store pointer to http_auth_require_t, which is persistent
* and will be different for each realm + permissions combo)*/
http_auth_cache_entry * const ae =
- malloc(sizeof(http_auth_cache_entry) + ulen + pwlen
- + (k == username ? 0 : klen));
- force_assert(ae);
+ ck_malloc(sizeof(http_auth_cache_entry) + ulen + pwlen
+ + (k == username ? 0 : klen));
ae->require = require;
ae->ctime = log_monotonic_secs;
ae->dalgo = dalgo;
@@ -106,8 +105,7 @@ http_auth_cache_free (http_auth_cache *ac)
static http_auth_cache *
http_auth_cache_init (const array *opts)
{
- http_auth_cache *ac = malloc(sizeof(http_auth_cache));
- force_assert(ac);
+ http_auth_cache *ac = ck_malloc(sizeof(http_auth_cache));
ac->sptree = NULL;
ac->max_age = 600; /* 10 mins */
for (uint32_t i = 0, used = opts->used; i < used; ++i) {
@@ -224,8 +222,7 @@ INIT_FUNC(mod_auth_init) {
static http_auth_scheme_t http_auth_scheme_basic = { "basic", mod_auth_check_basic, NULL };
static http_auth_scheme_t http_auth_scheme_digest = { "digest", mod_auth_check_digest, NULL };
static const http_auth_scheme_t http_auth_scheme_extern = { "extern", mod_auth_check_extern, NULL };
- plugin_data *p = calloc(1, sizeof(*p));
- force_assert(p);
+ plugin_data *p = ck_calloc(1, sizeof(*p));
/* register http_auth_scheme_* */
http_auth_scheme_basic.p_d = p;
@@ -283,8 +280,7 @@ static data_auth *data_auth_init(void)
data_auth_free,
NULL, /* insert_dup must not be called on this data */
};
- data_auth * const dauth = calloc(1, sizeof(*dauth));
- force_assert(NULL != dauth);
+ data_auth * const dauth = ck_calloc(1, sizeof(*dauth));
dauth->type = TYPE_OTHER;
dauth->fn = &fn;