ASF Bugzilla – Attachment 16429 Details for
Bug 36563
mod_ldap caching breaks when value is NULL
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Backported patch to fix invalid cache content handling
util_ldap_cache_fix.patch (text/plain), 4.17 KB, created by
Ondrej Sury
on 2005-09-16 23:04:42 UTC
(
hide
)
Description:
Backported patch to fix invalid cache content handling
Filename:
MIME Type:
Creator:
Ondrej Sury
Created:
2005-09-16 23:04:42 UTC
Size:
4.17 KB
patch
obsolete
>diff -urN httpd-2.0.54~/modules/experimental/util_ldap.c httpd-2.0.54/modules/experimental/util_ldap.c >--- httpd-2.0.54~/modules/experimental/util_ldap.c 2005-04-11 17:49:57.000000000 +0200 >+++ httpd-2.0.54/modules/experimental/util_ldap.c 2005-09-16 22:58:15.000000000 +0200 >@@ -749,6 +749,7 @@ > const char ***retvals) > { > const char **vals = NULL; >+ int numvals = 0; > int result = 0; > LDAPMessage *res, *entry; > char *dn; >@@ -912,6 +913,7 @@ > int i = 0; > while (attrs[k++]); > vals = apr_pcalloc(r->pool, sizeof(char *) * (k+1)); >+ numvals = k; > while (attrs[i]) { > char **values; > int j = 0; >@@ -939,6 +941,7 @@ > the_search_node.bindpw = bindpw; > the_search_node.lastbind = apr_time_now(); > the_search_node.vals = vals; >+ the_search_node.numvals = numvals; > > /* Search again to make sure that another thread didn't ready insert this node > into the cache before we got here. If it does exist then update the lastbind */ >@@ -981,6 +984,7 @@ > const char ***retvals) > { > const char **vals = NULL; >+ int numvals = 0; > int result = 0; > LDAPMessage *res, *entry; > char *dn; >@@ -1095,6 +1099,7 @@ > int i = 0; > while (attrs[k++]); > vals = apr_pcalloc(r->pool, sizeof(char *) * (k+1)); >+ numvals = k; > while (attrs[i]) { > char **values; > int j = 0; >@@ -1122,6 +1127,7 @@ > the_search_node.bindpw = NULL; > the_search_node.lastbind = apr_time_now(); > the_search_node.vals = vals; >+ the_search_node.numvals = numvals; > > /* Search again to make sure that another thread didn't ready insert this node > into the cache before we got here. If it does exist then update the lastbind */ >diff -urN httpd-2.0.54~/modules/experimental/util_ldap_cache.c httpd-2.0.54/modules/experimental/util_ldap_cache.c >--- httpd-2.0.54~/modules/experimental/util_ldap_cache.c 2005-02-04 21:21:18.000000000 +0100 >+++ httpd-2.0.54/modules/experimental/util_ldap_cache.c 2005-09-16 22:58:15.000000000 +0200 >@@ -158,18 +158,22 @@ > > /* copy vals */ > if (node->vals) { >- int k = 0; >+ int k = node->numvals; > int i = 0; >- while (node->vals[k++]); > if (!(newnode->vals = util_ald_alloc(cache, sizeof(char *) * (k+1)))) { > util_ldap_search_node_free(cache, newnode); > return NULL; > } >- while (node->vals[i]) { >- if (!(newnode->vals[i] = util_ald_strdup(cache, node->vals[i]))) { >- util_ldap_search_node_free(cache, newnode); >- return NULL; >+ newnode->numvals = node->numvals; >+ for (;k;k--) { >+ if (node->vals[i]) { >+ if (!(newnode->vals[i] = util_ald_strdup(cache, node->vals[i]))) { >+ util_ldap_search_node_free(cache, newnode); >+ return NULL; >+ } > } >+ else >+ newnode->vals[i] = NULL; > i++; > } > } >@@ -199,9 +203,13 @@ > { > int i = 0; > util_search_node_t *node = (util_search_node_t *)n; >+ int k = node->numvals; >+ > if (node->vals) { >- while (node->vals[i]) { >- util_ald_free(cache, node->vals[i++]); >+ for (;k;k--,i++) { >+ if (node->vals[i]) { >+ util_ald_free(cache, node->vals[i]); >+ } > } > util_ald_free(cache, node->vals); > } >diff -urN httpd-2.0.54~/modules/experimental/util_ldap_cache.h httpd-2.0.54/modules/experimental/util_ldap_cache.h >--- httpd-2.0.54~/modules/experimental/util_ldap_cache.h 2005-02-04 21:21:18.000000000 +0100 >+++ httpd-2.0.54/modules/experimental/util_ldap_cache.h 2005-09-16 22:58:49.000000000 +0200 >@@ -110,6 +110,7 @@ > NULL if the bind failed */ > apr_time_t lastbind; /* Time of last successful bind */ > const char **vals; /* Values of queried attributes */ >+ int numvals; /* Number of queried attributes */ > } util_search_node_t; > > /*
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 36563
: 16429