ASF Bugzilla – Attachment 21242 Details for
Bug 43942
httpd crashes while loading ldap attributes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch - optimized attribute handling
patch_43942.diff (text/plain), 3.71 KB, created by
Bernd Leinfelder
on 2007-12-07 05:01:05 UTC
(
hide
)
Description:
Patch - optimized attribute handling
Filename:
MIME Type:
Creator:
Bernd Leinfelder
Created:
2007-12-07 05:01:05 UTC
Size:
3.71 KB
patch
obsolete
>--- httpd-2.2.6/modules/ldap/util_ldap.c 2007-08-20 01:19:46.000000000 +0200 >+++ httpd-2.2.6-swisslife/modules/ldap/util_ldap.c 2007-12-07 10:41:44.000000000 +0100 >@@ -45,6 +45,8 @@ > #include "unixd.h" > #endif > >+#define ATTRIBUTE_VALUE_SIZE 256 >+ > /* defines for certificate file types > */ > #define LDAP_CA_TYPE_UNKNOWN 0 >@@ -1038,16 +1040,45 @@ > char **values; > int j = 0; > char *str = NULL; >+ int len = 0; >+ int size = 0; >+ int maxsize = 0; >+ int nextsize = 0; >+ char *buffer = NULL; >+ > /* get values */ > values = ldap_get_values(ldc->ldap, entry, attrs[i]); >- while (values && values[j]) { >- str = str ? apr_pstrcat(r->pool, str, "; ", values[j], NULL) >- : apr_pstrdup(r->pool, values[j]); >+ >+ maxsize = ldap_count_values(values) * ATTRIBUTE_VALUE_SIZE; >+ >+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, >+ "[%" APR_PID_T_FMT "] ldap cache: allocating %i bytes for attribute values", >+ getpid(), maxsize); >+ >+ buffer = apr_pcalloc(r->pool,maxsize); >+ str = buffer; >+ >+ while (values && values[j] && nextsize < maxsize) { >+ len=strlen(values[j]); >+ buffer[0]=';'; >+ memcpy(++buffer, values[j], len); >+ buffer+=len; >+ size+=len; > j++; >+ >+ nextsize=size+strlen(values[j]); >+ >+ if (nextsize >= maxsize) { >+ ap_log_error(APLOG_MARK, APLOG_WARNING , 0, r->server, >+ "[%" APR_PID_T_FMT "] ldap cache: buffer overflow while storing attributes values. attribute %s has more than %i bytes ", >+ getpid(), attrs[i], maxsize); >+ } >+ > } > ldap_value_free(values); > vals[i] = str; > i++; >+ > } > *retvals = vals; > } >@@ -1233,12 +1264,40 @@ > char **values; > int j = 0; > char *str = NULL; >+ int len = 0; >+ int size = 0; >+ int maxsize = 0; >+ int nextsize = 0; >+ char *buffer = NULL; >+ > /* get values */ > values = ldap_get_values(ldc->ldap, entry, attrs[i]); >- while (values && values[j]) { >- str = str ? apr_pstrcat(r->pool, str, "; ", values[j], NULL) >- : apr_pstrdup(r->pool, values[j]); >+ >+ maxsize = ldap_count_values(values) * ATTRIBUTE_VALUE_SIZE; >+ >+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, >+ "[%" APR_PID_T_FMT "] ldap cache: allocating %i bytes for attribute values", >+ getpid(), maxsize); >+ >+ buffer = apr_pcalloc(r->pool,maxsize); >+ str = buffer; >+ >+ while (values && values[j] && nextsize < maxsize) { >+ len=strlen(values[j]); >+ buffer[0]=';'; >+ memcpy(++buffer, values[j], len); >+ buffer+=len; >+ size+=len; > j++; >+ >+ nextsize=size+strlen(values[j]); >+ >+ if (nextsize >= maxsize) { >+ ap_log_error(APLOG_MARK, APLOG_WARNING , 0, r->server, >+ "[%" APR_PID_T_FMT "] ldap cache: buffer overflow while storing attributes values. attribute %s has more than %i bytes ", >+ getpid(), attrs[i], maxsize); >+ } >+ > } > ldap_value_free(values); > vals[i] = str;
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 43942
:
21240
| 21242