Projects
home:connyhald:branches:Kolab:3.3:Updates
cyrus-imapd
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 11
View file
ptloader-segfault.patch
Changed
@@ -1,105 +1,82 @@ --- a/ptclient/ldap.c +++ b/ptclient/ldap.c -@@ -888,6 +888,7 @@ static int ptsmodule_get_dn( - LDAPControl c; - LDAPControl *ctrl2; - char *authzid; -+ - #endif - char *base = NULL, *filter = NULL; - char *domain = NULL; -@@ -901,16 +902,21 @@ static int ptsmodule_get_dn( - - *ret = NULL; - -- if (ptsm->ld == NULL) -+ -+ if (ptsm->ld == NULL) { -+ syslog(LOG_WARNING, "SEGV: ptsm->ld == NULL. Return PTSM_FAIL."); - return PTSM_FAIL; -+ } - - #if LDAP_VENDOR_VERSION >= 20125 - - if (ptsm->sasl) { - - authzid = xmalloc(size + sizeof("u:")); -- if (authzid == NULL) -+ if (authzid == NULL) { -+ syslog(LOG_WARNING, "SEGV: authzid == NULL. Return PTSM_NOMEM."); - return PTSM_NOMEM; -+ } - - strcpy(authzid, "u:"); - strcpy(authzid+2, canon_id); -@@ -927,8 +933,10 @@ static int ptsmodule_get_dn( - if (rc == LDAP_SERVER_DOWN) { - ldap_unbind(ptsm->ld); - ptsm->ld = NULL; -+ syslog(LOG_WARNING, "SEGV: rc == LDAP_SERVER_DOWN. Return PTSM_RETRY."); - return PTSM_RETRY; -- } -+ } -+ syslog(LOG_WARNING, "SEGV: rc != LDAP_SUCCESS. Return PTSM_FAIL."); - return PTSM_FAIL; - } - -@@ -943,8 +951,10 @@ static int ptsmodule_get_dn( - - { - rc = ptsmodule_expand_tokens(ptsm->filter, canon_id, NULL, &filter); -- if (rc != PTSM_OK) -+ if (rc != PTSM_OK) { -+ syslog(LOG_WARNING, "SEGV: rc != PTSM_OK. Return rc: %i", rc); - return rc; -+ } - - if (ptsm->domain_base_dn && ptsm->domain_base_dn0 != '\0' && (strrchr(canon_id, '@') != NULL)) { - syslog(LOG_DEBUG, "Attempting to get domain for %s from %s", canon_id, ptsm->domain_base_dn); -@@ -989,6 +999,7 @@ static int ptsmodule_get_dn( - } - - if (rc != PTSM_OK) { -+ syslog(LOG_WARNING, "SEGV: rc != PTSM_OK (2). Return rc: %i", rc); - return rc; - } else { - base = xstrdup(ptsm->base); -@@ -999,10 +1010,17 @@ static int ptsmodule_get_dn( - - } else { - rc = ptsmodule_expand_tokens(ptsm->base, canon_id, NULL, &base); -- if (rc != PTSM_OK) -+ if (rc != PTSM_OK) { -+ syslog(LOG_WARNING, "SEGV: rc != PTSM_OK (3). Return rc: %i", rc); - return rc; -+ } - } -+ -+ // Log parameters to find SIGV -+ syslog(LOG_WARNING, "SEGV: ld: x, base: %s, scope: %i, filter: %s, attrs: x, timeout: %ld.%06d", -+ base, ptsm->scope, filter, ptsm->timeout.tv_sec, ptsm->timeout.tv_usec); +@@ -630,59 +630,60 @@ static int ptsmodule_escape( + + static int *ptsmodule_standard_root_dn(const char *domain, const char **result) + { +- /* number of dots */ +- int dots; + /* the expected length of the result */ +- int root_dn_len; + + char *buf; + char *part; + char *ptr; ++ char *dc=",dc="; ++ char *dn=NULL; ++ dn = xzmalloc(1024); ++ buf = xzmalloc(1024); ++ buf0 = '\0'; // (?) ++ dn0 = '\0'; // (?) + + syslog(LOG_DEBUG, "ptsmodule_standard_root_dn called for domain %s", domain); + +- for (dots = 0, buf=(char *)domain; *buf; buf++) { +- if (*buf == '.') { +- dots++; +- } +- } ++ strncpy(dn, domain, strlen(domain)); + + /* Each dot is to be replaced with ',dc=' (length 4), so add + * length 3 for each of them. + */ +- root_dn_len = strlen(domain) + (dots * 3); + +- buf = xmalloc(root_dn_len); ++ buf = xzmalloc(1024); + buf0 = '\0'; // (?) + /* AM: Above: Terminate the string by default, so strlen won't buffer-overflow later */ + + /* AM: No need for another allocation/dup */ +- part = strtok_r(domain, ".", &ptr); ++ part = strtok_r(dn, ".", &ptr); + + while (part != NULL) { +- syslog(LOG_DEBUG, "Root DN now %s", buf); +- strcat(buf, ",dc="); +- syslog(LOG_DEBUG, "Root DN now %s", buf); +- strcat(buf, part); +- syslog(LOG_DEBUG, "Root DN now %s", buf); +- part = strtok_r(NULL, ".", &ptr); ++ syslog(LOG_DEBUG, "Root DN now %s", buf); ++ strncat(buf, dc, strlen(dc)); ++ syslog(LOG_DEBUG, "Root DN now %s", buf); ++ strncat(buf, part, strlen(part)); ++ syslog(LOG_DEBUG, "Root DN now %s", buf); ++ part = strtok_r(NULL, ".", &ptr); + } -+ // Next line crashes sometimes - rc = ldap_search_st(ptsm->ld, base, ptsm->scope, filter, attrs, 0, &(ptsm->timeout), &res); + syslog(LOG_DEBUG, "Root DN now %s", buf); - if (rc != LDAP_SUCCESS) { -@@ -1013,9 +1031,11 @@ static int ptsmodule_get_dn( - if (rc == LDAP_SERVER_DOWN) { - ldap_unbind(ptsm->ld); - ptsm->ld = NULL; -+ syslog(LOG_WARNING, "SEGV: rc == LDAP_SERVER_DOWN. Return PTSM_RETRY."); - return PTSM_RETRY; - } + if (buf0 == ',') +- memmove(buf, buf+1, strlen(buf)); ++ memmove(buf, buf+1, strlen(buf)); -+ syslog(LOG_WARNING, "SEGV: rc != LDAP_SUCCESS (2). Return PTSM_FAIL."); - return PTSM_FAIL; - } ++ strcat(buf,"\0"); + *result = xstrdup(buf); -@@ -1041,6 +1061,7 @@ static int ptsmodule_get_dn( - res = NULL; - } + free(buf); + free(part); ++ free(dn); ++ + /* free(ptr); +- free(root_dn_len); + */ + syslog(LOG_DEBUG, "Root DN now %s", *result); -+ syslog(LOG_WARNING, "SEGV: Reached last return. Ret: %s", (*ret ? *ret : "NULL")); - return (*ret ? PTSM_OK : PTSM_FAIL); + return PTSM_OK; ++ } + static int ptsmodule_tokenize_domains( \ No newline at end of file
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.