Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 312094 Details for
Bug 442011
Asterisk crashed when using realtime LDAP backend
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Patch to fix crash in asterisk's LDAP backend
asterisk-1.6.0-beta9-crashfix.diff (text/plain), 11.65 KB, created by
W. Michael Petullo
on 2008-07-18 02:34:18 UTC
(
hide
)
Description:
Patch to fix crash in asterisk's LDAP backend
Filename:
MIME Type:
Creator:
W. Michael Petullo
Created:
2008-07-18 02:34:18 UTC
Size:
11.65 KB
patch
obsolete
>diff -u --recursive asterisk-1.6.0-beta9-vanilla/res/res_config_ldap.c asterisk-1.6.0-beta9/res/res_config_ldap.c >--- asterisk-1.6.0-beta9-vanilla/res/res_config_ldap.c 2008-07-17 20:46:01.000000000 -0400 >+++ asterisk-1.6.0-beta9/res/res_config_ldap.c 2008-07-17 21:00:27.000000000 -0400 >@@ -43,7 +43,7 @@ > #include <stdio.h> > #include <ldap.h> > >-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 115524 $") >+ASTERISK_FILE_VERSION(__FILE__, "$Revision$") > > #include "asterisk/channel.h" > #include "asterisk/logger.h" >@@ -282,33 +282,36 @@ > > values = ldap_get_values_len(ldapConn, ldap_entry, ldap_attribute_name); /* these are freed at the end */ > if (values) { >- struct berval **v = values; >+ struct berval **v; >+ char *valptr; > >- while (*v) { >+ for (v = values; *v; v++) { > value = *v; >- ast_debug(2, "LINE(%d) attribute_name: %s LDAP value: %s\n", __LINE__, attribute_name, value->bv_val); >+ valptr = value->bv_val; >+ ast_debug(2, "LINE(%d) attribute_name: %s LDAP value: %s\n", __LINE__, attribute_name, valptr); > if (is_realmed_password_attribute) { >- if (!strncasecmp(value->bv_val, "{md5}", 5)) >- value->bv_val += 5; >- else >- value->bv_val = NULL; >- ast_debug(2, "md5: %s\n", value->bv_val); >+ if (!strncasecmp(valptr, "{md5}", 5)) { >+ valptr += 5; >+ } else { >+ valptr = NULL; >+ } >+ ast_debug(2, "md5: %s\n", valptr); > } >- if (value->bv_val) { >+ if (valptr) { > /* ok, so looping through all delimited values except the last one (not, last character is not delimited...) */ > if (is_delimited) { > i = 0; > pos = 0; >- while (!ast_strlen_zero(value->bv_val + i)) { >- if (value->bv_val[i] == ';'){ >- value->bv_val[i] = '\0'; >+ while (!ast_strlen_zero(valptr + i)) { >+ if (valptr[i] == ';'){ >+ valptr[i] = '\0'; > if (prev) { >- prev->next = ast_variable_new(attribute_name, &value->bv_val[pos], table_config->table_name); >+ prev->next = ast_variable_new(attribute_name, &valptr[pos], table_config->table_name); > if (prev->next) { > prev = prev->next; > } > } else { >- prev = var = ast_variable_new(attribute_name, &value->bv_val[pos], table_config->table_name); >+ prev = var = ast_variable_new(attribute_name, &valptr[pos], table_config->table_name); > } > pos = i + 1; > } >@@ -317,15 +320,14 @@ > } > /* for the last delimited value or if the value is not delimited: */ > if (prev) { >- prev->next = ast_variable_new(attribute_name, &value->bv_val[pos], table_config->table_name); >+ prev->next = ast_variable_new(attribute_name, &valptr[pos], table_config->table_name); > if (prev->next) { > prev = prev->next; > } > } else { >- prev = var = ast_variable_new(attribute_name, &value->bv_val[pos], table_config->table_name); >+ prev = var = ast_variable_new(attribute_name, &valptr[pos], table_config->table_name); > } > } >- v++; > } > ldap_value_free_len(values); > } >@@ -400,23 +402,27 @@ > > values = ldap_get_values_len(ldapConn, ldap_entry, ldap_attribute_name); > if (values) { >- struct berval **v = values; >+ struct berval **v; >+ char *valptr; > >- while (*v) { >+ for (v = values; *v; v++) { > value = *v; >+ valptr = value->bv_val; > if (is_realmed_password_attribute) { >- if (strncasecmp(value->bv_val, "{md5}", 5) == 0) >- value->bv_val += 5; >- else >- value->bv_val = NULL; >- ast_debug(2, "md5: %s\n", value->bv_val); >+ if (strncasecmp(valptr, "{md5}", 5) == 0) { >+ printf("foo\n"); >+ valptr += 5; >+ } else { >+ valptr = NULL; >+ } >+ ast_debug(2, "md5: %s\n", valptr); > } >- if (value->bv_val) { >+ if (valptr) { > if (delim_value == NULL > && !is_realmed_password_attribute > && (static_table_config != table_config || strcmp(attribute_name, "variable_value") == 0)) { > >- delim_value = ast_strdup(value->bv_val); >+ delim_value = ast_strdup(valptr); > > if ((delim_tot_count = semicolon_count_str(delim_value)) > 0) { > ast_debug(4, "LINE(%d) is delimited %d times: %s\n", __LINE__, delim_tot_count, delim_value); >@@ -426,11 +432,10 @@ > > if (is_delimited != 0 > && !is_realmed_password_attribute >- && (static_table_config != table_config || strcmp(attribute_name, "variable_value") == 0) ){ >+ && (static_table_config != table_config || strcmp(attribute_name, "variable_value") == 0) ) { > /* for non-Static RealTime, first */ > >- i = pos; >- while (!ast_strlen_zero(value->bv_val + i)) { >+ for (i = pos; !ast_strlen_zero(valptr + i); i++) { > ast_debug(4, "LINE(%d) DELIM pos: %d i: %d\n", __LINE__, pos, i); > if (delim_value[i] == ';') { > delim_value[i] = '\0'; >@@ -451,9 +456,8 @@ > break; > } > } >- i++; > } >- if (ast_strlen_zero(value->bv_val + i)) { >+ if (ast_strlen_zero(valptr + i)) { > ast_debug(4, "LINE(%d) DELIM pos: %d i: %d delim_count: %d\n", __LINE__, pos, i, delim_count); > /* Last delimited value */ > ast_debug(4, "LINE(%d) DELIM - attribute_name: %s value: %s pos: %d\n", __LINE__, attribute_name, &delim_value[pos], pos); >@@ -468,9 +472,9 @@ > /* Remembering to free memory */ > is_delimited = 0; > pos = 0; >- free(delim_value); >- delim_value = NULL; > } >+ free(delim_value); >+ delim_value = NULL; > > ast_debug(4, "LINE(%d) DELIM pos: %d i: %d\n", __LINE__, pos, i); > } else { >@@ -479,20 +483,19 @@ > free(delim_value); > delim_value = NULL; > } >- ast_debug(2, "LINE(%d) attribute_name: %s value: %s\n", __LINE__, attribute_name, value->bv_val); >+ ast_debug(2, "LINE(%d) attribute_name: %s value: %s\n", __LINE__, attribute_name, valptr); > > if (prev) { >- prev->next = ast_variable_new(attribute_name, value->bv_val, table_config->table_name); >+ prev->next = ast_variable_new(attribute_name, valptr, table_config->table_name); > if (prev->next) { > prev = prev->next; > } > } else { >- prev = var = ast_variable_new(attribute_name, value->bv_val, table_config->table_name); >+ prev = var = ast_variable_new(attribute_name, valptr, table_config->table_name); > } > } > } >- v++; >- } /*!< while(*v) */ >+ } /*!< for (v = values; *v; v++) */ > ldap_value_free_len(values); > }/*!< if (values) */ > ldap_attribute_name = ldap_next_attribute(ldapConn, ldap_entry, ber); >@@ -586,9 +589,9 @@ > > vars = realtime_ldap_result_to_vars(table_config, ldap_result, entries_count_ptr); > if (num_entry > 1) >- ast_log(LOG_WARNING, "More than one entry for dn=%s. Take only 1st one\n", dn); >+ ast_log(LOG_NOTICE, "More than one entry for dn=%s. Take only 1st one\n", dn); > } else { >- ast_log(LOG_WARNING, "Could not find any entry dn=%s.\n", dn); >+ ast_debug(2, "Could not find any entry dn=%s.\n", dn); > } > } > ldap_msgfree(ldap_result); >@@ -814,7 +817,7 @@ > /* is this a static var or some other? they are handled different for delimited values */ > vars = realtime_ldap_result_to_vars(table_config, ldap_result, entries_count_ptr); > } else { >- ast_log(LOG_WARNING, "Could not find any entry matching %s in base dn %s.\n", >+ ast_debug(1, "Could not find any entry matching %s in base dn %s.\n", > filter->str, clean_basedn); > } > >@@ -940,7 +943,7 @@ > if (vars) { > cfg = ast_config_new(); > if (!cfg) { >- ast_log(LOG_WARNING, "Out of memory!\n"); >+ ast_log(LOG_ERROR, "Unable to create a config!\n"); > } else { > struct ast_variable **p = vars; > >@@ -948,7 +951,7 @@ > struct ast_category *cat = NULL; > cat = ast_category_new("", table_name, -1); > if (!cat) { >- ast_log(LOG_WARNING, "Out of memory!\n"); >+ ast_log(LOG_ERROR, "Unable to create a new category!\n"); > break; > } else { > struct ast_variable *var = *p; >@@ -1020,7 +1023,7 @@ > struct ast_variable **p; > > if (ast_strlen_zero(file) || !strcasecmp(file, RES_CONFIG_LDAP_CONF)) { >- ast_log(LOG_WARNING, "Cannot configure myself.\n"); >+ ast_log(LOG_ERROR, "Cannot configure myself.\n"); > return NULL; > } > >@@ -1189,7 +1192,7 @@ > newval = va_arg(ap, const char *); > if (!newparam || !newval) { > ast_log(LOG_WARNING, >- "LINE(%d): need at least one paramter to modify.\n", __LINE__); >+ "LINE(%d): need at least one parameter to modify.\n", __LINE__); > return -1; > } > >@@ -1432,7 +1435,7 @@ > } else > ast_copy_string(basedn, s, sizeof(basedn)); > >- if (!(s = ast_variable_retrieve(config, "_general", "version")) || !(s = ast_variable_retrieve(config, "_general", "protocol"))) { >+ if (!(s = ast_variable_retrieve(config, "_general", "version")) && !(s = ast_variable_retrieve(config, "_general", "protocol"))) { > ast_log(LOG_NOTICE, "No explicit LDAP version found, using 3 as default.\n"); > version = 3; > } else if (sscanf(s, "%d", &version) != 1 || version < 1 || version > 6) { >@@ -1459,10 +1462,11 @@ > static_table_config = table_config; > } > for (; var; var = var->next) { >- if (!strcasecmp(var->name, "additionalFilter")) >- table_config->additional_filter = strdup(var->value); >- else >+ if (!strcasecmp(var->name, "additionalFilter")) { >+ table_config->additional_filter = ast_strdup(var->value); >+ } else { > ldap_table_config_add_attribute(table_config, var->name, var->value); >+ } > } > } > } >@@ -1504,7 +1508,9 @@ > bind_result = ldap_sasl_bind_s(ldapConn, user, LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL); > } else { > ast_debug(2, "bind %s anonymously\n", url); >- bind_result = ldap_sasl_bind_s(ldapConn, NULL, LDAP_SASL_SIMPLE, NULL, NULL, NULL, NULL); >+ cred.bv_val = NULL; >+ cred.bv_len = 0; >+ bind_result = ldap_sasl_bind_s(ldapConn, NULL, LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL); > } > if (bind_result == LDAP_SUCCESS) { > ast_debug(2, "Successfully connected to database.\n"); >@@ -1520,7 +1526,7 @@ > > static char *realtime_ldap_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) > { >- char status[256], status2[100] = ""; >+ char status[256], credentials[100] = ""; > int ctime = time(NULL) - connect_time; > > switch (cmd) { >@@ -1541,26 +1547,26 @@ > snprintf(status, sizeof(status), "Connected to '%s', baseDN %s", url, basedn); > > if (!ast_strlen_zero(user)) >- snprintf(status2, sizeof(status2), " with username %s", user); >+ snprintf(credentials, sizeof(credentials), " with username %s", user); > > if (ctime > 31536000) { > ast_cli(a->fd, "%s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n", >- status, status2, ctime / 31536000, >+ status, credentials, ctime / 31536000, > (ctime % 31536000) / 86400, (ctime % 86400) / 3600, > (ctime % 3600) / 60, ctime % 60); > } else if (ctime > 86400) { > ast_cli(a->fd, "%s%s for %d days, %d hours, %d minutes, %d seconds.\n", >- status, status2, ctime / 86400, (ctime % 86400) / 3600, >+ status, credentials, ctime / 86400, (ctime % 86400) / 3600, > (ctime % 3600) / 60, ctime % 60); > } else if (ctime > 3600) { > ast_cli(a->fd, "%s%s for %d hours, %d minutes, %d seconds.\n", >- status, status2, ctime / 3600, (ctime % 3600) / 60, >+ status, credentials, ctime / 3600, (ctime % 3600) / 60, > ctime % 60); > } else if (ctime > 60) { >- ast_cli(a->fd, "%s%s for %d minutes, %d seconds.\n", status, status2, >+ ast_cli(a->fd, "%s%s for %d minutes, %d seconds.\n", status, credentials, > ctime / 60, ctime % 60); > } else { >- ast_cli(a->fd, "%s%s for %d seconds.\n", status, status2, ctime); >+ ast_cli(a->fd, "%s%s for %d seconds.\n", status, credentials, ctime); > } > > return CLI_SUCCESS;
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 442011
:
302098
| 312094