From f8dda515699b63542c9cd9cf62dff1c8e5feda1e Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Nov 22 2005 03:40:14 +0000 Subject: Cannot pass const strings into slapi_str2filter, since it can modify the contents. I'm not sure why we haven't caught this earlier, but I believe it has something to do with the patch to make ds build on Fedora Core 4 with gcc4. To do that, we turn off the -fwriteable-strings argument to gcc. I suppose with it on, it moves those strings to some sort of writeable memory location. With it off, constant strings are definitely in the data section. There was one place in views that used a constant string, and a couple of places in the windows sync code. --- diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c index 76fa15e..827f7ab 100644 --- a/ldap/servers/plugins/replication/windows_protocol_util.c +++ b/ldap/servers/plugins/replication/windows_protocol_util.c @@ -1570,11 +1570,12 @@ is_tombstone(Slapi_Entry *e) { int retval = 0; - char *string_deleted = "(isdeleted=*)"; + char *string_deleted = slapi_ch_strdup("(isdeleted=*)"); /* DBDB: we should allocate these filters once and keep them around for better performance */ Slapi_Filter *filter_deleted = slapi_str2filter( string_deleted ); + slapi_ch_free_string(&string_deleted); /* DBDB: this should be one filter, the code originally tested separately and hasn't been fixed yet */ if ( (slapi_filter_test_simple( e, filter_deleted ) == 0) ) { @@ -2251,9 +2252,10 @@ is_subject_of_agreemeent_local(const Slapi_Entry *local_entry, const Repl_Agmt * /* Next test for the correct kind of entry */ if (local_entry) { /* DBDB: we should allocate these filters once and keep them around for better performance */ - char *string_filter = "(&(|(objectclass=ntuser)(objectclass=ntgroup))(ntUserDomainId=*))"; + char *string_filter = slapi_ch_strdup("(&(|(objectclass=ntuser)(objectclass=ntgroup))(ntUserDomainId=*))"); Slapi_Filter *filter = slapi_str2filter( string_filter ); + slapi_ch_free_string(&string_filter); if (slapi_filter_test_simple( (Slapi_Entry*)local_entry, filter ) == 0) { retval = 1; diff --git a/ldap/servers/plugins/views/views.c b/ldap/servers/plugins/views/views.c index d5c7e69..6d3fddf 100644 --- a/ldap/servers/plugins/views/views.c +++ b/ldap/servers/plugins/views/views.c @@ -735,6 +735,7 @@ static void views_cache_create_applied_filter(viewEntry *pView) Slapi_Filter *pCurrentFilter = 0; Slapi_Filter *pBuiltFilter = 0; Slapi_Filter *pViewEntryExcludeFilter = 0; + char *excludeFilter; if(pView->includeAncestorFiltersFilter) { @@ -769,7 +770,11 @@ static void views_cache_create_applied_filter(viewEntry *pView) } /* filter for removing view entries from search */ - pViewEntryExcludeFilter = slapi_str2filter( "(!(objectclass=" VIEW_OBJECTCLASS "))" ); + /* richm - slapi_str2filter _writes_ to it's argument, so we have to pass in + some writeable memory, or core dump, do not pass go */ + excludeFilter = slapi_ch_strdup("(!(objectclass=" VIEW_OBJECTCLASS "))"); + pViewEntryExcludeFilter = slapi_str2filter( excludeFilter ); + slapi_ch_free_string(&excludeFilter); if(pBuiltFilter) pView->includeAncestorFiltersFilter = slapi_filter_join_ex( LDAP_FILTER_AND, pBuiltFilter, pViewEntryExcludeFilter, 0 );