mirror of
https://github.com/apache/httpd.git
synced 2025-08-07 04:02:58 +03:00
Added some bulletproofing to memory allocation in the LDAP cache
code. PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@90789 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -1,5 +1,8 @@
|
|||||||
Changes with Apache 2.0.26-dev
|
Changes with Apache 2.0.26-dev
|
||||||
|
|
||||||
|
*) Added some bulletproofing to memory allocation in the LDAP cache
|
||||||
|
code. [Graham Leggett]
|
||||||
|
|
||||||
Changes with Apache 2.0.25
|
Changes with Apache 2.0.25
|
||||||
|
|
||||||
*) Move the installed /manual directory out of the /htdocs/ tree, so
|
*) Move the installed /manual directory out of the /htdocs/ tree, so
|
||||||
|
@@ -90,12 +90,20 @@ void *util_ldap_url_node_copy(void *c)
|
|||||||
util_url_node_t *n = (util_url_node_t *)c;
|
util_url_node_t *n = (util_url_node_t *)c;
|
||||||
util_url_node_t *node = (util_url_node_t *)util_ald_alloc(sizeof(util_url_node_t));
|
util_url_node_t *node = (util_url_node_t *)util_ald_alloc(sizeof(util_url_node_t));
|
||||||
|
|
||||||
node->url = util_ald_strdup(n->url);
|
if (node) {
|
||||||
|
if (!(node->url = util_ald_strdup(n->url))) {
|
||||||
|
util_ald_free(node->url);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
node->search_cache = n->search_cache;
|
node->search_cache = n->search_cache;
|
||||||
node->compare_cache = n->compare_cache;
|
node->compare_cache = n->compare_cache;
|
||||||
node->dn_compare_cache = n->dn_compare_cache;
|
node->dn_compare_cache = n->dn_compare_cache;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void util_ldap_url_node_free(void *n)
|
void util_ldap_url_node_free(void *n)
|
||||||
{
|
{
|
||||||
@@ -200,13 +208,22 @@ void *util_ldap_compare_node_copy(void *c)
|
|||||||
{
|
{
|
||||||
util_compare_node_t *n = (util_compare_node_t *)c;
|
util_compare_node_t *n = (util_compare_node_t *)c;
|
||||||
util_compare_node_t *node = (util_compare_node_t *)util_ald_alloc(sizeof(util_compare_node_t));
|
util_compare_node_t *node = (util_compare_node_t *)util_ald_alloc(sizeof(util_compare_node_t));
|
||||||
node->dn = util_ald_strdup(n->dn);
|
|
||||||
node->attrib = util_ald_strdup(n->attrib);
|
if (node) {
|
||||||
node->value = util_ald_strdup(n->value);
|
if (!(node->dn = util_ald_strdup(n->dn)) ||
|
||||||
|
!(node->attrib = util_ald_strdup(n->attrib)) ||
|
||||||
|
!(node->value = util_ald_strdup(n->value))) {
|
||||||
|
util_ldap_compare_node_free(node);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
node->lastcompare = n->lastcompare;
|
node->lastcompare = n->lastcompare;
|
||||||
node->result = n->result;
|
node->result = n->result;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void util_ldap_compare_node_free(void *n)
|
void util_ldap_compare_node_free(void *n)
|
||||||
{
|
{
|
||||||
@@ -234,10 +251,18 @@ void *util_ldap_dn_compare_node_copy(void *c)
|
|||||||
{
|
{
|
||||||
util_dn_compare_node_t *n = (util_dn_compare_node_t *)c;
|
util_dn_compare_node_t *n = (util_dn_compare_node_t *)c;
|
||||||
util_dn_compare_node_t *node = (util_dn_compare_node_t *)util_ald_alloc(sizeof(util_dn_compare_node_t));
|
util_dn_compare_node_t *node = (util_dn_compare_node_t *)util_ald_alloc(sizeof(util_dn_compare_node_t));
|
||||||
node->reqdn = util_ald_strdup(n->reqdn);
|
if (node) {
|
||||||
node->dn = util_ald_strdup(n->dn);
|
if (!(node->reqdn = util_ald_strdup(n->reqdn)) ||
|
||||||
|
!(node->dn = util_ald_strdup(n->dn))) {
|
||||||
|
util_ldap_dn_compare_node_free(node);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void util_ldap_dn_compare_node_free(void *n)
|
void util_ldap_dn_compare_node_free(void *n)
|
||||||
{
|
{
|
||||||
|
@@ -193,7 +193,7 @@ void util_ldap_dn_compare_node_free(void *n);
|
|||||||
/* util_ldap_cache_mgr.c */
|
/* util_ldap_cache_mgr.c */
|
||||||
|
|
||||||
void util_ald_free(const void *ptr);
|
void util_ald_free(const void *ptr);
|
||||||
void *util_ald_alloc(int size);
|
void *util_ald_alloc(unsigned long size);
|
||||||
const char *util_ald_strdup(const char *s);
|
const char *util_ald_strdup(const char *s);
|
||||||
unsigned long util_ald_hash_string(int nstr, ...);
|
unsigned long util_ald_hash_string(int nstr, ...);
|
||||||
void util_ald_cache_purge(util_ald_cache_t *cache);
|
void util_ald_cache_purge(util_ald_cache_t *cache);
|
||||||
|
@@ -128,8 +128,10 @@ void util_ald_free(const void *ptr)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void *util_ald_alloc(int size)
|
void *util_ald_alloc(unsigned long size)
|
||||||
{
|
{
|
||||||
|
if (0 == size)
|
||||||
|
return NULL;
|
||||||
#if APR_HAS_SHARED_MEMORY
|
#if APR_HAS_SHARED_MEMORY
|
||||||
if (util_ldap_shm) {
|
if (util_ldap_shm) {
|
||||||
return (void *)apr_shm_calloc(util_ldap_shm, size);
|
return (void *)apr_shm_calloc(util_ldap_shm, size);
|
||||||
@@ -137,7 +139,7 @@ void *util_ald_alloc(int size)
|
|||||||
return (void *)calloc(sizeof(char), size);
|
return (void *)calloc(sizeof(char), size);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return (void *)calloc(size);
|
return (void *)calloc(sizeof(char), size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,6 +205,9 @@ void util_ald_cache_purge(util_ald_cache_t *cache)
|
|||||||
util_cache_node_t *p, *q;
|
util_cache_node_t *p, *q;
|
||||||
apr_time_t t;
|
apr_time_t t;
|
||||||
|
|
||||||
|
if (!cache)
|
||||||
|
return;
|
||||||
|
|
||||||
cache->last_purge = apr_time_now();
|
cache->last_purge = apr_time_now();
|
||||||
cache->npurged = 0;
|
cache->npurged = 0;
|
||||||
cache->numpurges++;
|
cache->numpurges++;
|
||||||
|
Reference in New Issue
Block a user