Branch '389-ds-base-1.3.1' - ldap/servers
by Richard Allen Megginson
ldap/servers/slapd/entrywsi.c | 5 ++++-
ldap/servers/slapd/proto-slap.h | 2 +-
ldap/servers/slapd/valueset.c | 35 ++++++++++++++++++++++++++---------
3 files changed, 31 insertions(+), 11 deletions(-)
New commits:
commit e218c71c15f668db3cc5e121d9401391718b7676
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Mon Jul 29 21:13:57 2013 -0600
Ticket #47456 - delete present values should append values to deleted values
https://fedorahosted.org/389/ticket/47456
Reviewed by: lkrispenz (Thanks!)
Branch: master
Fix Description: When deleting all values, entry_delete_present_values_wsi was
deleting all values in the deleted_values set and replacing them with the
present_values set. It should not delete the values in the deleted_values
set, it should just add to them. This also renames valueset_add_valueset
to valueset_set_valueset, which is what it was doing anyway.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/slapd/entrywsi.c b/ldap/servers/slapd/entrywsi.c
index c993950..248a41f 100644
--- a/ldap/servers/slapd/entrywsi.c
+++ b/ldap/servers/slapd/entrywsi.c
@@ -548,7 +548,10 @@ entry_delete_present_values_wsi(Slapi_Entry *e, const char *type, struct berval
if(!slapi_attr_flag_is_set(a,SLAPI_ATTR_FLAG_SINGLE))
{
/* We don't maintain a deleted value list for single valued attributes */
- valueset_add_valueset(&a->a_deleted_values, &a->a_present_values); /* JCM Would be better to passin the valuestodelete */
+ /* Add each deleted value to the deleted set */
+ slapi_valueset_add_attr_valuearray_ext (a,
+ &a->a_deleted_values, a->a_present_values.va, a->a_present_values.num, SLAPI_VALUE_FLAG_PASSIN, NULL);
+ slapi_ch_free((void **)&a->a_present_values.va);
}
slapi_valueset_done(&a->a_present_values);
entry_present_attribute_to_deleted_attribute(e, a);
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index cdcc952..60fa4e4 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -183,7 +183,7 @@ void valueset_add_valuearray(Slapi_ValueSet *vs, Slapi_Value **addvals);
void valueset_add_valuearray_ext(Slapi_ValueSet *vs, Slapi_Value **addvals, PRUint32 flags);
void valueset_add_string(const Slapi_Attr *a, Slapi_ValueSet *vs, const char *s, CSNType t, const CSN *csn);
void valueset_update_csn(Slapi_ValueSet *vs, CSNType t, const CSN *csn);
-void valueset_add_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
+void valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
Slapi_ValueSet *valueset_dup(const Slapi_ValueSet *dupee);
void valueset_remove_string(const Slapi_Attr *a, Slapi_ValueSet *vs, const char *s);
int valueset_replace_valuearray(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value **vals);
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index e473497..6c7d2e4 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -661,6 +661,9 @@ valueset_set_valuearray_byval(Slapi_ValueSet *vs, Slapi_Value **addvals)
PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
+/* WARNING: you must call this function with a new vs - if it points to existing data, it
+ * will leak - call slapi_valueset_done to free it first if necessary
+ */
void
valueset_set_valuearray_passin(Slapi_ValueSet *vs, Slapi_Value **addvals)
{
@@ -671,18 +674,21 @@ valueset_set_valuearray_passin(Slapi_ValueSet *vs, Slapi_Value **addvals)
PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
+/* WARNING: you must call this function with a new vs1 - if it points to existing data, it
+ * will leak - call slapi_valueset_done(vs1) to free it first if necessary
+ */
void
slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
{
slapi_valueset_init(vs1);
- valueset_add_valueset(vs1,vs2);
+ valueset_set_valueset(vs1,vs2);
}
void
slapi_valueset_join_attr_valueset(const Slapi_Attr *a, Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
{
if (slapi_valueset_isempty(vs1))
- valueset_add_valueset(vs1,vs2);
+ valueset_set_valueset(vs1,vs2);
else
slapi_valueset_add_attr_valuearray_ext (a, vs1, vs2->va, vs2->num, 0, NULL);
}
@@ -763,7 +769,7 @@ valueset_remove_value_sorted(const Slapi_Attr *a, Slapi_ValueSet *vs, const Slap
memmove(&vs->sorted[position],&vs->sorted[position+1],(vs->num - position)*sizeof(int));
memmove(&vs->va[index],&vs->va[index+1],(vs->num - index)*sizeof(Slapi_Value *));
vs->num--;
- /* unfortunately the references in the sorted array
+ /* unfortunately the references in the sorted array
* to values past the removed one are no longer correct
* need to adjust */
for (i=0; i < vs->num; i++) {
@@ -1176,13 +1182,14 @@ valueset_add_string(const Slapi_Attr *a, Slapi_ValueSet *vs, const char *s, CSNT
* The value set is passed in by value.
*/
void
-valueset_add_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
+valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
{
int i;
if (vs1 && vs2) {
- valuearray_free(&vs1->va);
- slapi_ch_free((void **)&vs1->sorted);
+ int oldmax = vs1->max;
+ /* pre-condition - vs1 empty - otherwise, existing data is overwritten */
+ PR_ASSERT(vs1->num == 0);
if (vs2->va) {
/* need to copy valuearray */
if (vs2->max == 0) {
@@ -1193,16 +1200,26 @@ valueset_add_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
vs1->num = vs2->num;
vs1->max = vs2->max;
}
- vs1->va = (Slapi_Value **) slapi_ch_malloc( vs1->max * sizeof(Slapi_Value *));
+ /* do we need more room? */
+ if ((NULL == vs1->va) || (oldmax < vs1->max)) {
+ vs1->va = (Slapi_Value **)slapi_ch_realloc((char *)vs1->va, vs1->max * sizeof(Slapi_Value *));
+ }
for (i=0; i< vs1->num;i++) {
vs1->va[i] = slapi_value_dup(vs2->va[i]);
}
vs1->va[vs1->num] = NULL;
+ } else {
+ valuearray_free(&vs1->va);
}
if (vs2->sorted) {
- vs1->sorted = (int *) slapi_ch_malloc( vs1->max* sizeof(int));
- memcpy(&vs1->sorted[0],&vs2->sorted[0],vs1->num* sizeof(int));
+ if ((NULL == vs1->sorted) || (oldmax < vs1->max)) {
+ vs1->sorted = (int *)slapi_ch_realloc((char *)vs1->sorted, vs1->max * sizeof(int));
+ }
+ memcpy(&vs1->sorted[0], &vs2->sorted[0], vs1->num * sizeof(int));
+ } else {
+ slapi_ch_free((void **)&vs1->sorted);
}
+ /* post-condition */
PR_ASSERT((vs1->sorted == NULL) || (vs1->num == 0) || ((vs1->sorted[0] >= 0) && (vs1->sorted[0] < vs1->num)));
}
}
10 years, 9 months
ldap/servers
by Richard Allen Megginson
ldap/servers/slapd/proto-slap.h | 2 +-
ldap/servers/slapd/valueset.c | 35 ++++++++++++++++++++++++++---------
2 files changed, 27 insertions(+), 10 deletions(-)
New commits:
commit 50ba5a09068a4eaaa565cb96a80d0289b40f0cd4
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Mon Jul 29 21:13:57 2013 -0600
Ticket #47456 - delete present values should append values to deleted values
https://fedorahosted.org/389/ticket/47456
Reviewed by: lkrispenz (Thanks!)
Branch: master
Fix Description: When deleting all values, entry_delete_present_values_wsi was
deleting all values in the deleted_values set and replacing them with the
present_values set. It should not delete the values in the deleted_values
set, it should just add to them. This also renames valueset_add_valueset
to valueset_set_valueset, which is what it was doing anyway.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index a5317b4..e0c1a4e 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -182,8 +182,8 @@ void valueset_add_valuearray(Slapi_ValueSet *vs, Slapi_Value **addvals);
void valueset_add_valuearray_ext(Slapi_ValueSet *vs, Slapi_Value **addvals, PRUint32 flags);
void valueset_add_string(const Slapi_Attr *a, Slapi_ValueSet *vs, const char *s, CSNType t, const CSN *csn);
void valueset_update_csn(Slapi_ValueSet *vs, CSNType t, const CSN *csn);
-void valueset_add_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
int valueset_intersectswith_valuearray(Slapi_ValueSet *vs, const Slapi_Attr *a, Slapi_Value **values, int *duplicate_index);
+void valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2);
Slapi_ValueSet *valueset_dup(const Slapi_ValueSet *dupee);
void valueset_remove_string(const Slapi_Attr *a, Slapi_ValueSet *vs, const char *s);
int valueset_replace_valuearray(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value **vals);
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index 172882f..62dad9c 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -661,6 +661,9 @@ valueset_set_valuearray_byval(Slapi_ValueSet *vs, Slapi_Value **addvals)
PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
+/* WARNING: you must call this function with a new vs - if it points to existing data, it
+ * will leak - call slapi_valueset_done to free it first if necessary
+ */
void
valueset_set_valuearray_passin(Slapi_ValueSet *vs, Slapi_Value **addvals)
{
@@ -671,18 +674,21 @@ valueset_set_valuearray_passin(Slapi_ValueSet *vs, Slapi_Value **addvals)
PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
+/* WARNING: you must call this function with a new vs1 - if it points to existing data, it
+ * will leak - call slapi_valueset_done(vs1) to free it first if necessary
+ */
void
slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
{
slapi_valueset_init(vs1);
- valueset_add_valueset(vs1,vs2);
+ valueset_set_valueset(vs1,vs2);
}
void
slapi_valueset_join_attr_valueset(const Slapi_Attr *a, Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
{
if (slapi_valueset_isempty(vs1))
- valueset_add_valueset(vs1,vs2);
+ valueset_set_valueset(vs1,vs2);
else
slapi_valueset_add_attr_valuearray_ext (a, vs1, vs2->va, vs2->num, 0, NULL);
}
@@ -762,7 +768,7 @@ valueset_remove_value_sorted(const Slapi_Attr *a, Slapi_ValueSet *vs, const Slap
memmove(&vs->sorted[position],&vs->sorted[position+1],(vs->num - position)*sizeof(int));
memmove(&vs->va[index],&vs->va[index+1],(vs->num - index)*sizeof(Slapi_Value *));
vs->num--;
- /* unfortunately the references in the sorted array
+ /* unfortunately the references in the sorted array
* to values past the removed one are no longer correct
* need to adjust */
for (i=0; i < vs->num; i++) {
@@ -1173,13 +1179,14 @@ valueset_add_string(const Slapi_Attr *a, Slapi_ValueSet *vs, const char *s, CSNT
* The value set is passed in by value.
*/
void
-valueset_add_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
+valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
{
int i;
if (vs1 && vs2) {
- valuearray_free(&vs1->va);
- slapi_ch_free((void **)&vs1->sorted);
+ int oldmax = vs1->max;
+ /* pre-condition - vs1 empty - otherwise, existing data is overwritten */
+ PR_ASSERT(vs1->num == 0);
if (vs2->va) {
/* need to copy valuearray */
if (vs2->max == 0) {
@@ -1190,16 +1197,26 @@ valueset_add_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
vs1->num = vs2->num;
vs1->max = vs2->max;
}
- vs1->va = (Slapi_Value **) slapi_ch_malloc( vs1->max * sizeof(Slapi_Value *));
+ /* do we need more room? */
+ if ((NULL == vs1->va) || (oldmax < vs1->max)) {
+ vs1->va = (Slapi_Value **)slapi_ch_realloc((char *)vs1->va, vs1->max * sizeof(Slapi_Value *));
+ }
for (i=0; i< vs1->num;i++) {
vs1->va[i] = slapi_value_dup(vs2->va[i]);
}
vs1->va[vs1->num] = NULL;
+ } else {
+ valuearray_free(&vs1->va);
}
if (vs2->sorted) {
- vs1->sorted = (int *) slapi_ch_malloc( vs1->max* sizeof(int));
- memcpy(&vs1->sorted[0],&vs2->sorted[0],vs1->num* sizeof(int));
+ if ((NULL == vs1->sorted) || (oldmax < vs1->max)) {
+ vs1->sorted = (int *)slapi_ch_realloc((char *)vs1->sorted, vs1->max * sizeof(int));
+ }
+ memcpy(&vs1->sorted[0], &vs2->sorted[0], vs1->num * sizeof(int));
+ } else {
+ slapi_ch_free((void **)&vs1->sorted);
}
+ /* post-condition */
PR_ASSERT((vs1->sorted == NULL) || (vs1->num == 0) || ((vs1->sorted[0] >= 0) && (vs1->sorted[0] < vs1->num)));
}
}
10 years, 9 months
Branch '389-ds-base-1.3.1' - ldap/servers
by Richard Allen Megginson
ldap/servers/plugins/replication/cl5_api.c | 10 ++++-----
ldap/servers/plugins/replication/repl5_protocol.c | 2 -
ldap/servers/slapd/back-ldbm/import.c | 1
ldap/servers/slapd/daemon.c | 3 ++
ldap/servers/slapd/entry.c | 9 +++++---
ldap/servers/slapd/valueset.c | 23 ++++++++++++++++++++--
6 files changed, 37 insertions(+), 11 deletions(-)
New commits:
commit 5633e125a462fa174186d1a8adba3ee00c43e3cd
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Mon Jul 29 15:06:03 2013 -0600
Ticket #47455 - valgrind - value mem leaks, uninit mem usage
https://fedorahosted.org/389/ticket/47455
Reviewed by: lkrispenz, nhosoi (Thanks!)
Branch: master
Fix Description: Make sure to use slapi_valueset_done to free valuesets to
clean up everything. Make sure to free the values in valueset_set_valueset
before setting them. The calculation of the size of the values to write
to the changelog was wrong. It was finding the size of the length by doing
sizeof(bv.bv_len) which is 8 bytes on 64-bit platforms, but using PRInt32 which
is 4 bytes on all platforms to actually store the length. So each length
calculation was using an extra 4 bytes, and writing this as uninitialized
memory to the changelog db.
In slapi_valueset_add_attr_valuearray_ext(), if an error is returned, and
the PASSIN flag was used, set the vs->va[0] to NULL - this will allow the
called to use both slapi_valueset_done(vs) and valuearray_free(&addvals) -
addvals will still own all of the values.
Cleaned up some other memory leaks and uninitialized memory uses.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index c76cac6..995aefe 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -335,7 +335,7 @@ static int _cl5GetModSize (LDAPMod *mod);
static void _cl5ReadBerval (struct berval *bv, char** buff);
static void _cl5WriteBerval (struct berval *bv, char** buff);
static int _cl5ReadBervals (struct berval ***bv, char** buff, unsigned int size);
-static int _cl5WriteBervals (struct berval **bv, char** buff, unsigned int *size);
+static int _cl5WriteBervals (struct berval **bv, char** buff, u_int32_t *size);
/* replay iteration */
#ifdef FOR_DEBUGGING
@@ -2731,7 +2731,7 @@ static int _cl5GetModSize (LDAPMod *mod)
{
while (mod->mod_bvalues != NULL && mod->mod_bvalues[i] != NULL)
{
- size += mod->mod_bvalues[i]->bv_len + sizeof (mod->mod_bvalues[i]->bv_len);
+ size += (PRInt32)mod->mod_bvalues[i]->bv_len + sizeof (PRInt32);
i++;
}
}
@@ -2785,7 +2785,7 @@ static void _cl5WriteBerval (struct berval *bv, char** buff)
PRUint32 net_length = 0;
length = (PRUint32) bv->bv_len;
- net_length = PR_htonl(length);
+ net_length = PR_htonl(length);
memcpy(*buff, &net_length, sizeof (net_length));
*buff += sizeof (net_length);
@@ -2835,7 +2835,7 @@ static int _cl5ReadBervals (struct berval ***bv, char** buff, unsigned int size)
}
/* data format: <value count> <value size> <value> <value size> <value> ..... */
-static int _cl5WriteBervals (struct berval **bv, char** buff, unsigned int *size)
+static int _cl5WriteBervals (struct berval **bv, char** buff, u_int32_t *size)
{
PRInt32 count, net_count;
char *pos;
@@ -2847,7 +2847,7 @@ static int _cl5WriteBervals (struct berval **bv, char** buff, unsigned int *size
*size = sizeof (count);
for (count = 0; bv[count]; count ++)
{
- *size += sizeof (bv[count]->bv_len) + bv[count]->bv_len;
+ *size += (u_int32_t)(sizeof (PRInt32) + (PRInt32)bv[count]->bv_len);
}
/* allocate buffer */
diff --git a/ldap/servers/plugins/replication/repl5_protocol.c b/ldap/servers/plugins/replication/repl5_protocol.c
index 8373ba6..34fe8a0 100644
--- a/ldap/servers/plugins/replication/repl5_protocol.c
+++ b/ldap/servers/plugins/replication/repl5_protocol.c
@@ -91,7 +91,7 @@ Repl_Protocol *
prot_new(Repl_Agmt *agmt, int protocol_state)
{
Slapi_DN *replarea_sdn = NULL;
- Repl_Protocol *rp = (Repl_Protocol *)slapi_ch_malloc(sizeof(Repl_Protocol));
+ Repl_Protocol *rp = (Repl_Protocol *)slapi_ch_calloc(1, sizeof(Repl_Protocol));
rp->prp_incremental = rp->prp_total = rp->prp_active_protocol = NULL;
if (protocol_state == STATE_PERFORMING_TOTAL_UPDATE)
diff --git a/ldap/servers/slapd/back-ldbm/import.c b/ldap/servers/slapd/back-ldbm/import.c
index d341ea7..04da5a4 100644
--- a/ldap/servers/slapd/back-ldbm/import.c
+++ b/ldap/servers/slapd/back-ldbm/import.c
@@ -1558,6 +1558,7 @@ error:
instance_set_not_busy(job->inst);
import_free_job(job);
+ FREE(job);
if (producer)
FREE(producer);
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 62c263e..9119dfb 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -1210,6 +1210,7 @@ void slapd_daemon( daemon_ports_t *ports )
}
}
+ slapi_ch_free((void **)&listener_idxs);
/* We get here when the server is shutting down */
/* Do what we have to do before death */
@@ -1819,6 +1820,8 @@ compute_idletimeout( slapdFrontendConfig_t *fecfg, Connection *conn )
}
slapi_sdn_free(&anon_sdn);
+ } else {
+ idletimeout = fecfg->idletimeout;
}
slapi_ch_free_string(&anon_dn);
} else if ( conn->c_isroot ) {
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index d6f9fdd..bf4583c 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -1127,11 +1127,12 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
{
/* Failure adding to value tree */
LDAPDebug( LDAP_DEBUG_ANY, "str2entry_dupcheck: unexpected failure %d adding value\n", rc, 0, 0 );
+ slapi_value_free(&value); /* value not consumed - free it */
slapi_entry_free( e ); e = NULL;
goto free_and_return;
}
- slapi_value_free(&value);
+ slapi_value_free(&value); /* if rc is error, value was not consumed - free it */
}
/* All done with parsing. Now create the entry. */
@@ -1200,6 +1201,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
sa->sa_present_values.num,
SLAPI_VALUE_FLAG_PASSIN, NULL);
sa->sa_present_values.num= 0; /* The values have been consumed */
+ slapi_ch_free((void **)&sa->sa_present_values.va);
slapi_valueset_add_attr_valuearray_ext(
*a,
&(*a)->a_deleted_values,
@@ -1207,6 +1209,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
sa->sa_deleted_values.num,
SLAPI_VALUE_FLAG_PASSIN, NULL);
sa->sa_deleted_values.num= 0; /* The values have been consumed */
+ slapi_ch_free((void **)&sa->sa_deleted_values.va);
if(sa->sa_attributedeletioncsn!=NULL)
{
attr_set_deletion_csn(*a,sa->sa_attributedeletioncsn);
@@ -1252,8 +1255,8 @@ free_and_return:
for ( i = 0; i < nattrs; i++ )
{
slapi_ch_free((void **) &(attrs[ i ].sa_type));
- slapi_ch_free((void **) &(attrs[ i ].sa_present_values.va));
- slapi_ch_free((void **) &(attrs[ i ].sa_deleted_values.va));
+ slapi_valueset_done(&attrs[ i ].sa_present_values);
+ slapi_valueset_done(&attrs[ i ].sa_deleted_values);
attr_done( &attrs[ i ].sa_attr );
}
if (tree_attr_checking)
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index 2a664a1..e473497 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -1046,6 +1046,15 @@ valueset_insert_value_to_sorted(const Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_V
}
+/*
+ * If this function returns an error, it is safe to do both
+ * slapi_valueset_done(vs);
+ * and
+ * valuearray_free(&addvals);
+ * if there is an error and the PASSIN flag is used, the addvals array will own all of the values
+ * vs will own none of the values - so you should do both slapi_valueset_done(vs) and valuearray_free(&addvals)
+ * to clean up
+ */
int
slapi_valueset_add_attr_valuearray_ext(const Slapi_Attr *a, Slapi_ValueSet *vs,
Slapi_Value **addvals, int naddvals, unsigned long flags, int *dup_index)
@@ -1118,8 +1127,12 @@ slapi_valueset_add_attr_valuearray_ext(const Slapi_Attr *a, Slapi_ValueSet *vs,
if (dup < 0 ) {
rc = LDAP_TYPE_OR_VALUE_EXISTS;
if (dup_index) *dup_index = i;
- if ( !passin)
+ if (passin) {
+ /* we have to NULL out the first value so valuearray_free won't delete values in addvals */
+ (vs->va)[0] = NULL;
+ } else {
slapi_value_free(&(vs->va)[vs->num]);
+ }
break;
}
} else {
@@ -1348,11 +1361,17 @@ valueset_replace_valuearray_ext(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value *
PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
} else {
/* verify the given values are not duplicated. */
+ unsigned long flags = SLAPI_VALUE_FLAG_PASSIN|SLAPI_VALUE_FLAG_DUPCHECK;
Slapi_ValueSet *vs_new = slapi_valueset_new();
- rc = slapi_valueset_add_attr_valuearray_ext (a, vs_new, valstoreplace, vals_count, 0, NULL);
+ rc = slapi_valueset_add_attr_valuearray_ext (a, vs_new, valstoreplace, vals_count, flags, NULL);
if ( rc == LDAP_SUCCESS )
{
+ /* used passin, so vs_new owns all of the Slapi_Value* in valstoreplace
+ * so tell valuearray_free_ext to start at index vals_count, which is
+ * NULL, then just free valstoreplace
+ */
+ valuearray_free_ext(&valstoreplace, vals_count);
/* values look good - replace the values in the attribute */
if(!valuearray_isempty(vs->va))
{
10 years, 9 months
ldap/servers
by Richard Allen Megginson
ldap/servers/plugins/replication/cl5_api.c | 10 ++++-----
ldap/servers/plugins/replication/repl5_protocol.c | 2 -
ldap/servers/slapd/back-ldbm/import.c | 1
ldap/servers/slapd/daemon.c | 3 ++
ldap/servers/slapd/entry.c | 9 +++++---
ldap/servers/slapd/valueset.c | 23 ++++++++++++++++++++--
6 files changed, 37 insertions(+), 11 deletions(-)
New commits:
commit 39648c727d0b29e6f208cb9a698a54ab1c4be2fe
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Mon Jul 29 15:06:03 2013 -0600
Ticket #47455 - valgrind - value mem leaks, uninit mem usage
https://fedorahosted.org/389/ticket/47455
Reviewed by: lkrispenz, nhosoi (Thanks!)
Branch: master
Fix Description: Make sure to use slapi_valueset_done to free valuesets to
clean up everything. Make sure to free the values in valueset_set_valueset
before setting them. The calculation of the size of the values to write
to the changelog was wrong. It was finding the size of the length by doing
sizeof(bv.bv_len) which is 8 bytes on 64-bit platforms, but using PRInt32 which
is 4 bytes on all platforms to actually store the length. So each length
calculation was using an extra 4 bytes, and writing this as uninitialized
memory to the changelog db.
In slapi_valueset_add_attr_valuearray_ext(), if an error is returned, and
the PASSIN flag was used, set the vs->va[0] to NULL - this will allow the
called to use both slapi_valueset_done(vs) and valuearray_free(&addvals) -
addvals will still own all of the values.
Cleaned up some other memory leaks and uninitialized memory uses.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 5633e125a462fa174186d1a8adba3ee00c43e3cd)
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index e6f2d0c..0a70d6b 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -335,7 +335,7 @@ static int _cl5GetModSize (LDAPMod *mod);
static void _cl5ReadBerval (struct berval *bv, char** buff);
static void _cl5WriteBerval (struct berval *bv, char** buff);
static int _cl5ReadBervals (struct berval ***bv, char** buff, unsigned int size);
-static int _cl5WriteBervals (struct berval **bv, char** buff, unsigned int *size);
+static int _cl5WriteBervals (struct berval **bv, char** buff, u_int32_t *size);
/* replay iteration */
#ifdef FOR_DEBUGGING
@@ -2731,7 +2731,7 @@ static int _cl5GetModSize (LDAPMod *mod)
{
while (mod->mod_bvalues != NULL && mod->mod_bvalues[i] != NULL)
{
- size += mod->mod_bvalues[i]->bv_len + sizeof (mod->mod_bvalues[i]->bv_len);
+ size += (PRInt32)mod->mod_bvalues[i]->bv_len + sizeof (PRInt32);
i++;
}
}
@@ -2785,7 +2785,7 @@ static void _cl5WriteBerval (struct berval *bv, char** buff)
PRUint32 net_length = 0;
length = (PRUint32) bv->bv_len;
- net_length = PR_htonl(length);
+ net_length = PR_htonl(length);
memcpy(*buff, &net_length, sizeof (net_length));
*buff += sizeof (net_length);
@@ -2835,7 +2835,7 @@ static int _cl5ReadBervals (struct berval ***bv, char** buff, unsigned int size)
}
/* data format: <value count> <value size> <value> <value size> <value> ..... */
-static int _cl5WriteBervals (struct berval **bv, char** buff, unsigned int *size)
+static int _cl5WriteBervals (struct berval **bv, char** buff, u_int32_t *size)
{
PRInt32 count, net_count;
char *pos;
@@ -2847,7 +2847,7 @@ static int _cl5WriteBervals (struct berval **bv, char** buff, unsigned int *size
*size = sizeof (count);
for (count = 0; bv[count]; count ++)
{
- *size += sizeof (bv[count]->bv_len) + bv[count]->bv_len;
+ *size += (u_int32_t)(sizeof (PRInt32) + (PRInt32)bv[count]->bv_len);
}
/* allocate buffer */
diff --git a/ldap/servers/plugins/replication/repl5_protocol.c b/ldap/servers/plugins/replication/repl5_protocol.c
index 8373ba6..34fe8a0 100644
--- a/ldap/servers/plugins/replication/repl5_protocol.c
+++ b/ldap/servers/plugins/replication/repl5_protocol.c
@@ -91,7 +91,7 @@ Repl_Protocol *
prot_new(Repl_Agmt *agmt, int protocol_state)
{
Slapi_DN *replarea_sdn = NULL;
- Repl_Protocol *rp = (Repl_Protocol *)slapi_ch_malloc(sizeof(Repl_Protocol));
+ Repl_Protocol *rp = (Repl_Protocol *)slapi_ch_calloc(1, sizeof(Repl_Protocol));
rp->prp_incremental = rp->prp_total = rp->prp_active_protocol = NULL;
if (protocol_state == STATE_PERFORMING_TOTAL_UPDATE)
diff --git a/ldap/servers/slapd/back-ldbm/import.c b/ldap/servers/slapd/back-ldbm/import.c
index c7b52d9..aa6c707 100644
--- a/ldap/servers/slapd/back-ldbm/import.c
+++ b/ldap/servers/slapd/back-ldbm/import.c
@@ -1558,6 +1558,7 @@ error:
instance_set_not_busy(job->inst);
import_free_job(job);
+ FREE(job);
if (producer)
FREE(producer);
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index dae5f84..c4b0865 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -1210,6 +1210,7 @@ void slapd_daemon( daemon_ports_t *ports )
}
}
+ slapi_ch_free((void **)&listener_idxs);
/* We get here when the server is shutting down */
/* Do what we have to do before death */
@@ -1822,6 +1823,8 @@ compute_idletimeout( slapdFrontendConfig_t *fecfg, Connection *conn )
}
slapi_sdn_free(&anon_sdn);
+ } else {
+ idletimeout = fecfg->idletimeout;
}
slapi_ch_free_string(&anon_dn);
} else if ( conn->c_isroot ) {
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index 3c1c29b..4b119aa 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -1106,11 +1106,12 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
{
/* Failure adding to value tree */
LDAPDebug( LDAP_DEBUG_ANY, "str2entry_dupcheck: unexpected failure %d adding value\n", rc, 0, 0 );
+ slapi_value_free(&value); /* value not consumed - free it */
slapi_entry_free( e ); e = NULL;
goto free_and_return;
}
- slapi_value_free(&value);
+ slapi_value_free(&value); /* if rc is error, value was not consumed - free it */
}
/* All done with parsing. Now create the entry. */
@@ -1179,6 +1180,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
sa->sa_present_values.num,
SLAPI_VALUE_FLAG_PASSIN, NULL);
sa->sa_present_values.num= 0; /* The values have been consumed */
+ slapi_ch_free((void **)&sa->sa_present_values.va);
slapi_valueset_add_attr_valuearray_ext(
*a,
&(*a)->a_deleted_values,
@@ -1186,6 +1188,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
sa->sa_deleted_values.num,
SLAPI_VALUE_FLAG_PASSIN, NULL);
sa->sa_deleted_values.num= 0; /* The values have been consumed */
+ slapi_ch_free((void **)&sa->sa_deleted_values.va);
if(sa->sa_attributedeletioncsn!=NULL)
{
attr_set_deletion_csn(*a,sa->sa_attributedeletioncsn);
@@ -1231,8 +1234,8 @@ free_and_return:
for ( i = 0; i < nattrs; i++ )
{
slapi_ch_free((void **) &(attrs[ i ].sa_type));
- slapi_ch_free((void **) &(attrs[ i ].sa_present_values.va));
- slapi_ch_free((void **) &(attrs[ i ].sa_deleted_values.va));
+ slapi_valueset_done(&attrs[ i ].sa_present_values);
+ slapi_valueset_done(&attrs[ i ].sa_deleted_values);
attr_done( &attrs[ i ].sa_attr );
}
if (tree_attr_checking)
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index de576ec..172882f 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -1044,6 +1044,15 @@ valueset_insert_value_to_sorted(const Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_V
}
+/*
+ * If this function returns an error, it is safe to do both
+ * slapi_valueset_done(vs);
+ * and
+ * valuearray_free(&addvals);
+ * if there is an error and the PASSIN flag is used, the addvals array will own all of the values
+ * vs will own none of the values - so you should do both slapi_valueset_done(vs) and valuearray_free(&addvals)
+ * to clean up
+ */
int
slapi_valueset_add_attr_valuearray_ext(const Slapi_Attr *a, Slapi_ValueSet *vs,
Slapi_Value **addvals, int naddvals, unsigned long flags, int *dup_index)
@@ -1116,8 +1125,12 @@ slapi_valueset_add_attr_valuearray_ext(const Slapi_Attr *a, Slapi_ValueSet *vs,
if (dup < 0 ) {
rc = LDAP_TYPE_OR_VALUE_EXISTS;
if (dup_index) *dup_index = i;
- if ( !passin)
+ if (passin) {
+ /* we have to NULL out the first value so valuearray_free won't delete values in addvals */
+ (vs->va)[0] = NULL;
+ } else {
slapi_value_free(&(vs->va)[vs->num]);
+ }
break;
}
} else {
@@ -1345,11 +1358,17 @@ valueset_replace_valuearray_ext(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value *
PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
} else {
/* verify the given values are not duplicated. */
+ unsigned long flags = SLAPI_VALUE_FLAG_PASSIN|SLAPI_VALUE_FLAG_DUPCHECK;
Slapi_ValueSet *vs_new = slapi_valueset_new();
- rc = slapi_valueset_add_attr_valuearray_ext (a, vs_new, valstoreplace, vals_count, 0, NULL);
+ rc = slapi_valueset_add_attr_valuearray_ext (a, vs_new, valstoreplace, vals_count, flags, NULL);
if ( rc == LDAP_SUCCESS )
{
+ /* used passin, so vs_new owns all of the Slapi_Value* in valstoreplace
+ * so tell valuearray_free_ext to start at index vals_count, which is
+ * NULL, then just free valstoreplace
+ */
+ valuearray_free_ext(&valstoreplace, vals_count);
/* values look good - replace the values in the attribute */
if(!valuearray_isempty(vs->va))
{
10 years, 9 months
Branch '389-ds-base-1.3.1' - ldap/servers
by Richard Allen Megginson
ldap/servers/slapd/valueset.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
New commits:
commit df53a874436503ef99594fc09e3d817317f86940
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Mon Jul 29 12:36:02 2013 -0600
Ticket #47448 - Segfault in 389-ds-base-1.3.1.4-1.fc19 when setting up FreeIPA replication
https://fedorahosted.org/389/ticket/47448
Reviewed by: lkrispenz (Thanks!)
Branch: master
Fix Description: valueset_add_valueset() sets the values in the vs1
destination valueset. It expects that vs1 is empty. Particularly, the
sorted array. If the source valueset vs2->sorted is NULL, it assumes
vs1->sorted is NULL already, and does not free it and set it to NULL.
The fix is to free both vs1->sorted and vs1->va. NOTE: this fixes
the crash, but does not address the larger issue that the semantics of
valueset_add_valueset are not correct - valueset_add_valueset should add
the values from vs2 to vs1, rather than replace vs1 with vs2.
Also added post-condition assertions.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index 7ed8f36..2a664a1 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -605,6 +605,7 @@ slapi_valueset_done(Slapi_ValueSet *vs)
{
if(vs!=NULL)
{
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
if(vs->va!=NULL)
{
valuearray_free(&vs->va);
@@ -636,6 +637,7 @@ slapi_valueset_set_from_smod(Slapi_ValueSet *vs, Slapi_Mod *smod)
Slapi_Value **va= NULL;
valuearray_init_bervalarray(slapi_mod_get_ldapmod_byref(smod)->mod_bvalues, &va);
valueset_set_valuearray_passin(vs, va);
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
void
@@ -656,7 +658,7 @@ valueset_set_valuearray_byval(Slapi_ValueSet *vs, Slapi_Value **addvals)
}
}
vs->va[j] = NULL;
-
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
void
@@ -666,6 +668,7 @@ valueset_set_valuearray_passin(Slapi_ValueSet *vs, Slapi_Value **addvals)
vs->va= addvals;
vs->num = valuearray_count(addvals);
vs->max = vs->num + 1;
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
void
@@ -766,6 +769,7 @@ valueset_remove_value_sorted(const Slapi_Attr *a, Slapi_ValueSet *vs, const Slap
for (i=0; i < vs->num; i++) {
if (vs->sorted[i] > index) vs->sorted[i]--;
}
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
return r;
}
@@ -782,6 +786,7 @@ valueset_remove_value(const Slapi_Attr *a, Slapi_ValueSet *vs, const Slapi_Value
if (r)
vs->num--;
}
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
return r;
}
}
@@ -811,6 +816,7 @@ valueset_purge(Slapi_ValueSet *vs, const CSN *csn)
slapi_ch_free ((void **)&vs->sorted);
vs->sorted = NULL;
}
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
return 0;
@@ -1002,6 +1008,7 @@ valueset_array_to_sorted (const Slapi_Attr *a, Slapi_ValueSet *vs)
}
vs->sorted[j+1] = swap;
}
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
/* insert a value into a sorted array, if dupcheck is set no duplicate values will be accepted
* (is there a reason to allow duplicates ? LK
@@ -1017,10 +1024,12 @@ valueset_insert_value_to_sorted(const Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_V
if (vs->num == 0) {
vs->sorted[0] = 0;
vs->num++;
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
return(0);
} else if (valueset_value_cmp (a, vi, vs->va[vs->sorted[vs->num-1]]) > 0 ) {
vs->sorted[vs->num] = vs->num;
vs->num++;
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
return (vs->num);
}
v = valueset_find_sorted (a, vs, vi, &index);
@@ -1031,6 +1040,7 @@ valueset_insert_value_to_sorted(const Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_V
memmove(&vs->sorted[index+1],&vs->sorted[index],(vs->num - index)* sizeof(int));
vs->sorted[index] = vs->num;
vs->num++;
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
return(index);
}
@@ -1119,6 +1129,7 @@ slapi_valueset_add_attr_valuearray_ext(const Slapi_Attr *a, Slapi_ValueSet *vs,
}
(vs->va)[vs->num] = NULL;
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
return (rc);
}
@@ -1157,6 +1168,8 @@ valueset_add_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
int i;
if (vs1 && vs2) {
+ valuearray_free(&vs1->va);
+ slapi_ch_free((void **)&vs1->sorted);
if (vs2->va) {
/* need to copy valuearray */
if (vs2->max == 0) {
@@ -1177,6 +1190,7 @@ valueset_add_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
vs1->sorted = (int *) slapi_ch_malloc( vs1->max* sizeof(int));
memcpy(&vs1->sorted[0],&vs2->sorted[0],vs1->num* sizeof(int));
}
+ PR_ASSERT((vs1->sorted == NULL) || (vs1->num == 0) || ((vs1->sorted[0] >= 0) && (vs1->sorted[0] < vs1->num)));
}
}
@@ -1331,6 +1345,7 @@ valueset_replace_valuearray_ext(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value *
vs->va = valstoreplace;
vs->num = vals_count;
vs->max = vals_count + 1;
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
} else {
/* verify the given values are not duplicated. */
Slapi_ValueSet *vs_new = slapi_valueset_new();
@@ -1351,6 +1366,7 @@ valueset_replace_valuearray_ext(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value *
vs->num = vs_new->num;
vs->max = vs_new->max;
slapi_valueset_free (vs_new);
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
else
{
@@ -1358,6 +1374,7 @@ valueset_replace_valuearray_ext(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value *
use them, just delete them */
slapi_valueset_free(vs_new);
valuearray_free(&valstoreplace);
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
}
return rc;
10 years, 9 months
ldap/servers
by Richard Allen Megginson
ldap/servers/slapd/valueset.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
New commits:
commit ed89524bd7499419ebd31531d6a91c0284f60f81
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Mon Jul 29 12:36:02 2013 -0600
Ticket #47448 - Segfault in 389-ds-base-1.3.1.4-1.fc19 when setting up FreeIPA replication
https://fedorahosted.org/389/ticket/47448
Reviewed by: lkrispenz (Thanks!)
Branch: master
Fix Description: valueset_add_valueset() sets the values in the vs1
destination valueset. It expects that vs1 is empty. Particularly, the
sorted array. If the source valueset vs2->sorted is NULL, it assumes
vs1->sorted is NULL already, and does not free it and set it to NULL.
The fix is to free both vs1->sorted and vs1->va. NOTE: this fixes
the crash, but does not address the larger issue that the semantics of
valueset_add_valueset are not correct - valueset_add_valueset should add
the values from vs2 to vs1, rather than replace vs1 with vs2.
Also added post-condition assertions.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index 416a838..de576ec 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -605,6 +605,7 @@ slapi_valueset_done(Slapi_ValueSet *vs)
{
if(vs!=NULL)
{
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
if(vs->va!=NULL)
{
valuearray_free(&vs->va);
@@ -636,6 +637,7 @@ slapi_valueset_set_from_smod(Slapi_ValueSet *vs, Slapi_Mod *smod)
Slapi_Value **va= NULL;
valuearray_init_bervalarray(slapi_mod_get_ldapmod_byref(smod)->mod_bvalues, &va);
valueset_set_valuearray_passin(vs, va);
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
void
@@ -656,7 +658,7 @@ valueset_set_valuearray_byval(Slapi_ValueSet *vs, Slapi_Value **addvals)
}
}
vs->va[j] = NULL;
-
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
void
@@ -666,6 +668,7 @@ valueset_set_valuearray_passin(Slapi_ValueSet *vs, Slapi_Value **addvals)
vs->va= addvals;
vs->num = valuearray_count(addvals);
vs->max = vs->num + 1;
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
void
@@ -765,24 +768,27 @@ valueset_remove_value_sorted(const Slapi_Attr *a, Slapi_ValueSet *vs, const Slap
for (i=0; i < vs->num; i++) {
if (vs->sorted[i] > index) vs->sorted[i]--;
}
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
return r;
}
+
Slapi_Value *
valueset_remove_value(const Slapi_Attr *a, Slapi_ValueSet *vs, const Slapi_Value *v)
{
+ Slapi_Value *r = NULL;
if (vs->sorted) {
- return (valueset_remove_value_sorted(a, vs, v));
+ r = valueset_remove_value_sorted(a, vs, v);
} else {
- Slapi_Value *r= NULL;
if(!valuearray_isempty(vs->va))
{
r= valuearray_remove_value(a, vs->va, v);
if (r)
vs->num--;
}
- return r;
}
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
+ return r;
}
/*
@@ -809,6 +815,7 @@ valueset_purge(Slapi_ValueSet *vs, const CSN *csn)
slapi_ch_free ((void **)&vs->sorted);
vs->sorted = NULL;
}
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
return 0;
}
@@ -999,6 +1006,7 @@ valueset_array_to_sorted (const Slapi_Attr *a, Slapi_ValueSet *vs)
}
vs->sorted[j+1] = swap;
}
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
/* insert a value into a sorted array, if dupcheck is set no duplicate values will be accepted
* (is there a reason to allow duplicates ? LK
@@ -1014,10 +1022,12 @@ valueset_insert_value_to_sorted(const Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_V
if (vs->num == 0) {
vs->sorted[0] = 0;
vs->num++;
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
return(0);
} else if (valueset_value_cmp (a, vi, vs->va[vs->sorted[vs->num-1]]) > 0 ) {
vs->sorted[vs->num] = vs->num;
vs->num++;
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
return (vs->num);
}
v = valueset_find_sorted (a, vs, vi, &index);
@@ -1028,6 +1038,7 @@ valueset_insert_value_to_sorted(const Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_V
memmove(&vs->sorted[index+1],&vs->sorted[index],(vs->num - index)* sizeof(int));
vs->sorted[index] = vs->num;
vs->num++;
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
return(index);
}
@@ -1116,6 +1127,7 @@ slapi_valueset_add_attr_valuearray_ext(const Slapi_Attr *a, Slapi_ValueSet *vs,
}
(vs->va)[vs->num] = NULL;
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
return (rc);
}
@@ -1153,6 +1165,8 @@ valueset_add_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
int i;
if (vs1 && vs2) {
+ valuearray_free(&vs1->va);
+ slapi_ch_free((void **)&vs1->sorted);
if (vs2->va) {
/* need to copy valuearray */
if (vs2->max == 0) {
@@ -1173,6 +1187,7 @@ valueset_add_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2)
vs1->sorted = (int *) slapi_ch_malloc( vs1->max* sizeof(int));
memcpy(&vs1->sorted[0],&vs2->sorted[0],vs1->num* sizeof(int));
}
+ PR_ASSERT((vs1->sorted == NULL) || (vs1->num == 0) || ((vs1->sorted[0] >= 0) && (vs1->sorted[0] < vs1->num)));
}
}
@@ -1327,6 +1342,7 @@ valueset_replace_valuearray_ext(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value *
vs->va = valstoreplace;
vs->num = vals_count;
vs->max = vals_count + 1;
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
} else {
/* verify the given values are not duplicated. */
Slapi_ValueSet *vs_new = slapi_valueset_new();
@@ -1347,6 +1363,7 @@ valueset_replace_valuearray_ext(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value *
vs->num = vs_new->num;
vs->max = vs_new->max;
slapi_valueset_free (vs_new);
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
else
{
@@ -1354,6 +1371,7 @@ valueset_replace_valuearray_ext(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value *
use them, just delete them */
slapi_valueset_free(vs_new);
valuearray_free(&valstoreplace);
+ PR_ASSERT((vs->sorted == NULL) || (vs->num == 0) || ((vs->sorted[0] >= 0) && (vs->sorted[0] < vs->num)));
}
}
return rc;
10 years, 9 months
Branch '389-ds-base-1.3.0' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/back-ldbm/sort.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
New commits:
commit 835679247cf0207788a9f74131324ce05cf5de05
Author: Noriko Hosoi <nhosoi(a)totoro.usersys.redhat.com>
Date: Thu Jan 31 16:45:28 2013 -0800
Ticket #543 - Sorting with attributes in ldapsearch gives incorrect result
Bug description: In the server side sorting compare function
compare_entries_sv, if multiple attribute types are specified,
the sort spec for each attribute is scanned one by one in the
for loop. In the for loop, instead of using the "current"
spec, the first spec is kept using. If the attribute types
have different syntaxes (e.g., cis, tel), then the first
syntax is unexpectedly selected for the second syntax.
Fix description: This patch correctly uses the current spec
in the for loop.
Reviewed by Nathan (Thank you!!)
(cherry picked from commit 95f425da43b380163c2ddae66fc77d2b863a00e5)
diff --git a/ldap/servers/slapd/back-ldbm/sort.c b/ldap/servers/slapd/back-ldbm/sort.c
index 7768737..4164147 100644
--- a/ldap/servers/slapd/back-ldbm/sort.c
+++ b/ldap/servers/slapd/back-ldbm/sort.c
@@ -552,7 +552,7 @@ static int compare_entries_sv(ID *id_a, ID *id_b, sort_spec *s,baggage_carrier *
* doesn't try to free them. We need to note at the right place that
* we're on the matchrule path, and accordingly free the keys---this turns out
* to be when we free the indexer */
- if (NULL == s->matchrule) {
+ if (NULL == this_one->matchrule) {
/* Non-match rule case */
valuearray_get_bervalarray(valueset_get_valuearray(&attr_a->a_present_values),&value_a);
valuearray_get_bervalarray(valueset_get_valuearray(&attr_b->a_present_values),&value_b);
@@ -564,22 +564,22 @@ static int compare_entries_sv(ID *id_a, ID *id_b, sort_spec *s,baggage_carrier *
valuearray_get_bervalarray(valueset_get_valuearray(&attr_a->a_present_values),&actual_value_a);
valuearray_get_bervalarray(valueset_get_valuearray(&attr_b->a_present_values),&actual_value_b);
- matchrule_values_to_keys(s->mr_pb,actual_value_a,&temp_value);
+ matchrule_values_to_keys(this_one->mr_pb,actual_value_a,&temp_value);
/* Now copy it, so the second call doesn't crap on it */
value_a = slapi_ch_bvecdup(temp_value); /* Really, we'd prefer to not call the chXXX variant...*/
- matchrule_values_to_keys(s->mr_pb,actual_value_b,&value_b);
+ matchrule_values_to_keys(this_one->mr_pb,actual_value_b,&value_b);
if (actual_value_a) ber_bvecfree(actual_value_a);
if (actual_value_b) ber_bvecfree(actual_value_b);
}
/* Compare them */
if (!order) {
- result = sort_attr_compare(value_a, value_b, s->compare_fn);
+ result = sort_attr_compare(value_a, value_b, this_one->compare_fn);
} else {
/* If reverse, invert the sense of the comparison */
- result = sort_attr_compare(value_b, value_a, s->compare_fn);
+ result = sort_attr_compare(value_b, value_a, this_one->compare_fn);
}
/* Time to free up the attributes allocated above */
- if (NULL != s->matchrule) {
+ if (NULL != this_one->matchrule) {
ber_bvecfree(value_a);
} else {
ber_bvecfree(value_a);
10 years, 9 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/back-ldbm/sort.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
New commits:
commit 855d2890bc57482d7c22c6821a15b74f8053dc29
Author: Noriko Hosoi <nhosoi(a)totoro.usersys.redhat.com>
Date: Thu Jan 31 16:45:28 2013 -0800
Ticket #543 - Sorting with attributes in ldapsearch gives incorrect result
Bug description: In the server side sorting compare function
compare_entries_sv, if multiple attribute types are specified,
the sort spec for each attribute is scanned one by one in the
for loop. In the for loop, instead of using the "current"
spec, the first spec is kept using. If the attribute types
have different syntaxes (e.g., cis, tel), then the first
syntax is unexpectedly selected for the second syntax.
Fix description: This patch correctly uses the current spec
in the for loop.
Reviewed by Nathan (Thank you!!)
(cherry picked from commit 95f425da43b380163c2ddae66fc77d2b863a00e5)
diff --git a/ldap/servers/slapd/back-ldbm/sort.c b/ldap/servers/slapd/back-ldbm/sort.c
index 7768737..4164147 100644
--- a/ldap/servers/slapd/back-ldbm/sort.c
+++ b/ldap/servers/slapd/back-ldbm/sort.c
@@ -552,7 +552,7 @@ static int compare_entries_sv(ID *id_a, ID *id_b, sort_spec *s,baggage_carrier *
* doesn't try to free them. We need to note at the right place that
* we're on the matchrule path, and accordingly free the keys---this turns out
* to be when we free the indexer */
- if (NULL == s->matchrule) {
+ if (NULL == this_one->matchrule) {
/* Non-match rule case */
valuearray_get_bervalarray(valueset_get_valuearray(&attr_a->a_present_values),&value_a);
valuearray_get_bervalarray(valueset_get_valuearray(&attr_b->a_present_values),&value_b);
@@ -564,22 +564,22 @@ static int compare_entries_sv(ID *id_a, ID *id_b, sort_spec *s,baggage_carrier *
valuearray_get_bervalarray(valueset_get_valuearray(&attr_a->a_present_values),&actual_value_a);
valuearray_get_bervalarray(valueset_get_valuearray(&attr_b->a_present_values),&actual_value_b);
- matchrule_values_to_keys(s->mr_pb,actual_value_a,&temp_value);
+ matchrule_values_to_keys(this_one->mr_pb,actual_value_a,&temp_value);
/* Now copy it, so the second call doesn't crap on it */
value_a = slapi_ch_bvecdup(temp_value); /* Really, we'd prefer to not call the chXXX variant...*/
- matchrule_values_to_keys(s->mr_pb,actual_value_b,&value_b);
+ matchrule_values_to_keys(this_one->mr_pb,actual_value_b,&value_b);
if (actual_value_a) ber_bvecfree(actual_value_a);
if (actual_value_b) ber_bvecfree(actual_value_b);
}
/* Compare them */
if (!order) {
- result = sort_attr_compare(value_a, value_b, s->compare_fn);
+ result = sort_attr_compare(value_a, value_b, this_one->compare_fn);
} else {
/* If reverse, invert the sense of the comparison */
- result = sort_attr_compare(value_b, value_a, s->compare_fn);
+ result = sort_attr_compare(value_b, value_a, this_one->compare_fn);
}
/* Time to free up the attributes allocated above */
- if (NULL != s->matchrule) {
+ if (NULL != this_one->matchrule) {
ber_bvecfree(value_a);
} else {
ber_bvecfree(value_a);
10 years, 9 months
Branch '389-ds-base-1.3.1' - include/libaccess include/public ldap/servers lib/libaccess
by Mark Reynolds
include/libaccess/aclproto.h | 2 +-
include/public/nsacl/aclapi.h | 2 +-
include/public/nsacl/nserrdef.h | 2 +-
ldap/servers/plugins/acl/acl.c | 19 ++++++++++---------
ldap/servers/plugins/acl/acl.h | 2 +-
ldap/servers/plugins/acl/aclutil.c | 2 +-
lib/libaccess/nseframe.cpp | 2 +-
lib/libaccess/register.cpp | 2 +-
8 files changed, 17 insertions(+), 16 deletions(-)
New commits:
commit 857029bdf93dbbafe14b05e8f89d7707e9eb8160
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Jul 30 17:23:22 2013 -0400
Ticket 47440 - Fix runtime errors caused by last patch.
Author: richm
https://fedorahosted.org/389/ticket/47440
Reviewed by: mreynolds
(cherry picked from commit 1cc8ede3497d752555c23e1b9783550921b64fea)
diff --git a/include/libaccess/aclproto.h b/include/libaccess/aclproto.h
index 4579e8d..d30b406 100644
--- a/include/libaccess/aclproto.h
+++ b/include/libaccess/aclproto.h
@@ -112,7 +112,7 @@ NSAPI_PUBLIC int ACL_ListPostParseForAuth(NSErr_t *errp, ACLListHandle_t *acl_li
* ACL evaluation
*********************************************************************/
-NSAPI_PUBLIC int ACL_EvalTestRights(NSErr_t *errp, ACLEvalHandle_t *acleval, char **rights, char **map_generic, char **deny_type, char **deny_response, char **acl_tag, int *expr_num);
+NSAPI_PUBLIC int ACL_EvalTestRights(NSErr_t *errp, ACLEvalHandle_t *acleval, const char **rights, const char **map_generic, char **deny_type, char **deny_response, char **acl_tag, int *expr_num);
NSAPI_PUBLIC int ACL_CachableAclList(ACLListHandle_t *acllist);
NSAPI_PUBLIC ACLEvalHandle_t * ACL_EvalNew(NSErr_t *errp, pool_handle_t *pool);
NSAPI_PUBLIC void ACL_EvalDestroy(NSErr_t *errp, pool_handle_t *pool, ACLEvalHandle_t *acleval);
diff --git a/include/public/nsacl/aclapi.h b/include/public/nsacl/aclapi.h
index 3b2f641..e3abb25 100644
--- a/include/public/nsacl/aclapi.h
+++ b/include/public/nsacl/aclapi.h
@@ -240,7 +240,7 @@ struct ACLDispatchVector {
/* ACL evaluation */
int (*f_ACL_EvalTestRights)(NSErr_t *errp, ACLEvalHandle_t *acleval,
- char **rights, char **map_generic,
+ const char **rights, const char **map_generic,
char **deny_type, char **deny_response,
char **acl_tag, int *expr_num);
ACLEvalHandle_t * (*f_ACL_EvalNew)(NSErr_t *errp, pool_handle_t *pool);
diff --git a/include/public/nsacl/nserrdef.h b/include/public/nsacl/nserrdef.h
index 96857f4..52144e5 100644
--- a/include/public/nsacl/nserrdef.h
+++ b/include/public/nsacl/nserrdef.h
@@ -95,7 +95,7 @@ struct NSEFrame_s {
NSEFrame_t * ef_next; /* next error frame on NSErr_t list */
long ef_retcode; /* error return code */
long ef_errorid; /* error unique identifier */
- char * ef_program; /* context for ef_errorid */
+ const char * ef_program; /* context for ef_errorid */
int ef_errc; /* number of strings in ef_errv[] */
char * ef_errv[NSERRMAXARG];/* arguments for formatting error message */
};
diff --git a/ldap/servers/plugins/acl/acl.c b/ldap/servers/plugins/acl/acl.c
index 22c17dc..e0772ed 100644
--- a/ldap/servers/plugins/acl/acl.c
+++ b/ldap/servers/plugins/acl/acl.c
@@ -65,15 +65,15 @@ static short acl_signature = 0;
/****************************************************************************/
/* Defines, Constants, ande Declarations */
/****************************************************************************/
-static char *ds_map_generic[2] = { NULL, NULL };
+static const char *ds_map_generic[2] = { NULL, NULL };
/****************************************************************************/
/* prototypes */
/****************************************************************************/
static int acl__resource_match_aci(struct acl_pblock *aclpb, aci_t *aci ,
int skip_attrEval, int *a_matched);
-static int acl__TestRights(Acl_PBlock *aclpb,int access, char **right,
- char ** map_generic, aclResultReason_t *result_reason);
+static int acl__TestRights(Acl_PBlock *aclpb,int access, const char **right,
+ const char ** map_generic, aclResultReason_t *result_reason);
static int acl__scan_for_acis(struct acl_pblock *aclpb, int *err);
static void acl__reset_cached_result (struct acl_pblock *aclpb );
static int acl__scan_match_handles ( struct acl_pblock *aclpb, int type);
@@ -91,7 +91,7 @@ static int acl__test_filter ( Slapi_Entry *entry, struct slapi_filter *f,
static void print_access_control_summary( char * source,
int ret_val, char *clientDn,
struct acl_pblock *aclpb,
- char *right,
+ const char *right,
char *attr,
const char *edn,
aclResultReason_t *acl_reason);
@@ -247,7 +247,7 @@ acl_access_allowed(
int rv;
int err;
int ret_val;
- char *right;
+ const char *right;
struct acl_pblock *aclpb = NULL;
AclAttrEval *c_attrEval = NULL;
int got_reader_locked = 0;
@@ -658,7 +658,7 @@ cleanup_and_ret:
static void
print_access_control_summary( char *source, int ret_val, char *clientDn,
struct acl_pblock *aclpb,
- char *right,
+ const char *right,
char *attr,
const char *edn,
aclResultReason_t *acl_reason)
@@ -2733,7 +2733,7 @@ acl__resource_match_aci_EXIT:
*
**************************************************************************/
static int
-acl__TestRights(Acl_PBlock *aclpb,int access, char **right, char ** map_generic,
+acl__TestRights(Acl_PBlock *aclpb,int access, const char **right, const char ** map_generic,
aclResultReason_t *result_reason)
{
ACLEvalHandle_t *acleval;
@@ -2744,7 +2744,7 @@ acl__TestRights(Acl_PBlock *aclpb,int access, char **right, char ** map_generic,
char *deny_generic = NULL;
char *acl_tag;
int expr_num;
- char *testRights[2];
+ const char *testRights[2];
aci_t *aci = NULL;
int numHandles = 0;
@@ -3991,7 +3991,8 @@ acl__recompute_acl ( Acl_PBlock *aclpb,
char *unused_str1, *unused_str2;
- char *acl_tag, *testRight[2];
+ char *acl_tag;
+ const char *testRight[2];
int j, expr_num;
int result_status = ACL_RES_INVALID, cache_result;
PRUint32 cookie;
diff --git a/ldap/servers/plugins/acl/acl.h b/ldap/servers/plugins/acl/acl.h
index bedb6da..bf58f5c 100644
--- a/ldap/servers/plugins/acl/acl.h
+++ b/ldap/servers/plugins/acl/acl.h
@@ -846,7 +846,7 @@ void aclutil_print_err (int rv , const Slapi_DN *sdn,
const struct berval* val, char **errbuf);
void aclutil_print_aci (aci_t *aci_item, char *type);
short aclutil_gen_signature ( short c_signature );
-void aclutil_print_resource( struct acl_pblock *aclpb, char *right , char *attr, char *clientdn );
+void aclutil_print_resource( struct acl_pblock *aclpb, const char *right , char *attr, char *clientdn );
char * aclutil_expand_paramString ( char *str, Slapi_Entry *e );
diff --git a/ldap/servers/plugins/acl/aclutil.c b/ldap/servers/plugins/acl/aclutil.c
index 2002276..0915eab 100644
--- a/ldap/servers/plugins/acl/aclutil.c
+++ b/ldap/servers/plugins/acl/aclutil.c
@@ -498,7 +498,7 @@ aclutil_gen_signature ( short c_signature )
}
void
-aclutil_print_resource( struct acl_pblock *aclpb, char *right , char *attr, char *clientdn )
+aclutil_print_resource( struct acl_pblock *aclpb, const char *right , char *attr, char *clientdn )
{
char str[BUFSIZ];
diff --git a/lib/libaccess/nseframe.cpp b/lib/libaccess/nseframe.cpp
index 4a023e1..20c6d2b 100644
--- a/lib/libaccess/nseframe.cpp
+++ b/lib/libaccess/nseframe.cpp
@@ -197,7 +197,7 @@ void nserrFFree(NSErr_t * errp, NSEFrame_t * efp)
*/
NSEFrame_t * nserrGenerate(NSErr_t * errp, long retcode, long errorid,
- char * program, int errc, ...)
+ const char * program, int errc, ...)
{
NSEFrame_t * efp; /* error frame pointer */
char * esp; /* error string pointer */
diff --git a/lib/libaccess/register.cpp b/lib/libaccess/register.cpp
index 798a926..645b07b 100644
--- a/lib/libaccess/register.cpp
+++ b/lib/libaccess/register.cpp
@@ -164,7 +164,7 @@ ACL_LasHashDestroy()
* 0 on success, non-zero on failure
*/
NSAPI_PUBLIC int
-ACL_LasRegister(NSErr_t *errp, char *attr_name, LASEvalFunc_t eval_func,
+ACL_LasRegister(NSErr_t *errp, const char *attr_name, LASEvalFunc_t eval_func,
LASFlushFunc_t flush_func)
{
if ((!attr_name) || (!eval_func)) return -1;
10 years, 9 months
include/libaccess include/public ldap/servers lib/libaccess
by Mark Reynolds
include/libaccess/aclproto.h | 2 +-
include/public/nsacl/aclapi.h | 2 +-
include/public/nsacl/nserrdef.h | 2 +-
ldap/servers/plugins/acl/acl.c | 19 ++++++++++---------
ldap/servers/plugins/acl/acl.h | 2 +-
ldap/servers/plugins/acl/aclutil.c | 2 +-
lib/libaccess/nseframe.cpp | 2 +-
lib/libaccess/register.cpp | 2 +-
8 files changed, 17 insertions(+), 16 deletions(-)
New commits:
commit 1cc8ede3497d752555c23e1b9783550921b64fea
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Jul 30 17:23:22 2013 -0400
Ticket 47440 - Fix runtime errors caused by last patch.
Author: richm
https://fedorahosted.org/389/ticket/47440
Reviewed by: mreynolds
diff --git a/include/libaccess/aclproto.h b/include/libaccess/aclproto.h
index 4579e8d..d30b406 100644
--- a/include/libaccess/aclproto.h
+++ b/include/libaccess/aclproto.h
@@ -112,7 +112,7 @@ NSAPI_PUBLIC int ACL_ListPostParseForAuth(NSErr_t *errp, ACLListHandle_t *acl_li
* ACL evaluation
*********************************************************************/
-NSAPI_PUBLIC int ACL_EvalTestRights(NSErr_t *errp, ACLEvalHandle_t *acleval, char **rights, char **map_generic, char **deny_type, char **deny_response, char **acl_tag, int *expr_num);
+NSAPI_PUBLIC int ACL_EvalTestRights(NSErr_t *errp, ACLEvalHandle_t *acleval, const char **rights, const char **map_generic, char **deny_type, char **deny_response, char **acl_tag, int *expr_num);
NSAPI_PUBLIC int ACL_CachableAclList(ACLListHandle_t *acllist);
NSAPI_PUBLIC ACLEvalHandle_t * ACL_EvalNew(NSErr_t *errp, pool_handle_t *pool);
NSAPI_PUBLIC void ACL_EvalDestroy(NSErr_t *errp, pool_handle_t *pool, ACLEvalHandle_t *acleval);
diff --git a/include/public/nsacl/aclapi.h b/include/public/nsacl/aclapi.h
index 3b2f641..e3abb25 100644
--- a/include/public/nsacl/aclapi.h
+++ b/include/public/nsacl/aclapi.h
@@ -240,7 +240,7 @@ struct ACLDispatchVector {
/* ACL evaluation */
int (*f_ACL_EvalTestRights)(NSErr_t *errp, ACLEvalHandle_t *acleval,
- char **rights, char **map_generic,
+ const char **rights, const char **map_generic,
char **deny_type, char **deny_response,
char **acl_tag, int *expr_num);
ACLEvalHandle_t * (*f_ACL_EvalNew)(NSErr_t *errp, pool_handle_t *pool);
diff --git a/include/public/nsacl/nserrdef.h b/include/public/nsacl/nserrdef.h
index 96857f4..52144e5 100644
--- a/include/public/nsacl/nserrdef.h
+++ b/include/public/nsacl/nserrdef.h
@@ -95,7 +95,7 @@ struct NSEFrame_s {
NSEFrame_t * ef_next; /* next error frame on NSErr_t list */
long ef_retcode; /* error return code */
long ef_errorid; /* error unique identifier */
- char * ef_program; /* context for ef_errorid */
+ const char * ef_program; /* context for ef_errorid */
int ef_errc; /* number of strings in ef_errv[] */
char * ef_errv[NSERRMAXARG];/* arguments for formatting error message */
};
diff --git a/ldap/servers/plugins/acl/acl.c b/ldap/servers/plugins/acl/acl.c
index fb6c2d6..a05037c 100644
--- a/ldap/servers/plugins/acl/acl.c
+++ b/ldap/servers/plugins/acl/acl.c
@@ -65,15 +65,15 @@ static short acl_signature = 0;
/****************************************************************************/
/* Defines, Constants, ande Declarations */
/****************************************************************************/
-static char *ds_map_generic[2] = { NULL, NULL };
+static const char *ds_map_generic[2] = { NULL, NULL };
/****************************************************************************/
/* prototypes */
/****************************************************************************/
static int acl__resource_match_aci(struct acl_pblock *aclpb, aci_t *aci ,
int skip_attrEval, int *a_matched);
-static int acl__TestRights(Acl_PBlock *aclpb,int access, char **right,
- char ** map_generic, aclResultReason_t *result_reason);
+static int acl__TestRights(Acl_PBlock *aclpb,int access, const char **right,
+ const char ** map_generic, aclResultReason_t *result_reason);
static int acl__scan_for_acis(struct acl_pblock *aclpb, int *err);
static void acl__reset_cached_result (struct acl_pblock *aclpb );
static int acl__scan_match_handles ( struct acl_pblock *aclpb, int type);
@@ -91,7 +91,7 @@ static int acl__test_filter ( Slapi_Entry *entry, struct slapi_filter *f,
static void print_access_control_summary( char * source,
int ret_val, char *clientDn,
struct acl_pblock *aclpb,
- char *right,
+ const char *right,
char *attr,
const char *edn,
aclResultReason_t *acl_reason);
@@ -247,7 +247,7 @@ acl_access_allowed(
int rv;
int err;
int ret_val;
- char *right;
+ const char *right;
struct acl_pblock *aclpb = NULL;
AclAttrEval *c_attrEval = NULL;
int got_reader_locked = 0;
@@ -658,7 +658,7 @@ cleanup_and_ret:
static void
print_access_control_summary( char *source, int ret_val, char *clientDn,
struct acl_pblock *aclpb,
- char *right,
+ const char *right,
char *attr,
const char *edn,
aclResultReason_t *acl_reason)
@@ -2733,7 +2733,7 @@ acl__resource_match_aci_EXIT:
*
**************************************************************************/
static int
-acl__TestRights(Acl_PBlock *aclpb,int access, char **right, char ** map_generic,
+acl__TestRights(Acl_PBlock *aclpb,int access, const char **right, const char ** map_generic,
aclResultReason_t *result_reason)
{
ACLEvalHandle_t *acleval;
@@ -2744,7 +2744,7 @@ acl__TestRights(Acl_PBlock *aclpb,int access, char **right, char ** map_generic,
char *deny_generic = NULL;
char *acl_tag;
int expr_num;
- char *testRights[2];
+ const char *testRights[2];
aci_t *aci = NULL;
int numHandles = 0;
@@ -4015,7 +4015,8 @@ acl__recompute_acl ( Acl_PBlock *aclpb,
char *unused_str1, *unused_str2;
- char *acl_tag, *testRight[2];
+ char *acl_tag;
+ const char *testRight[2];
int j, expr_num;
int result_status = ACL_RES_INVALID, cache_result;
PRUint32 cookie;
diff --git a/ldap/servers/plugins/acl/acl.h b/ldap/servers/plugins/acl/acl.h
index 6fcef51..13c6f90 100644
--- a/ldap/servers/plugins/acl/acl.h
+++ b/ldap/servers/plugins/acl/acl.h
@@ -849,7 +849,7 @@ void aclutil_print_err (int rv , const Slapi_DN *sdn,
const struct berval* val, char **errbuf);
void aclutil_print_aci (aci_t *aci_item, char *type);
short aclutil_gen_signature ( short c_signature );
-void aclutil_print_resource( struct acl_pblock *aclpb, char *right , char *attr, char *clientdn );
+void aclutil_print_resource( struct acl_pblock *aclpb, const char *right , char *attr, char *clientdn );
char * aclutil_expand_paramString ( char *str, Slapi_Entry *e );
diff --git a/ldap/servers/plugins/acl/aclutil.c b/ldap/servers/plugins/acl/aclutil.c
index 4f81bc0..f33b11e 100644
--- a/ldap/servers/plugins/acl/aclutil.c
+++ b/ldap/servers/plugins/acl/aclutil.c
@@ -498,7 +498,7 @@ aclutil_gen_signature ( short c_signature )
}
void
-aclutil_print_resource( struct acl_pblock *aclpb, char *right , char *attr, char *clientdn )
+aclutil_print_resource( struct acl_pblock *aclpb, const char *right , char *attr, char *clientdn )
{
char str[BUFSIZ];
diff --git a/lib/libaccess/nseframe.cpp b/lib/libaccess/nseframe.cpp
index 4a023e1..20c6d2b 100644
--- a/lib/libaccess/nseframe.cpp
+++ b/lib/libaccess/nseframe.cpp
@@ -197,7 +197,7 @@ void nserrFFree(NSErr_t * errp, NSEFrame_t * efp)
*/
NSEFrame_t * nserrGenerate(NSErr_t * errp, long retcode, long errorid,
- char * program, int errc, ...)
+ const char * program, int errc, ...)
{
NSEFrame_t * efp; /* error frame pointer */
char * esp; /* error string pointer */
diff --git a/lib/libaccess/register.cpp b/lib/libaccess/register.cpp
index 798a926..645b07b 100644
--- a/lib/libaccess/register.cpp
+++ b/lib/libaccess/register.cpp
@@ -164,7 +164,7 @@ ACL_LasHashDestroy()
* 0 on success, non-zero on failure
*/
NSAPI_PUBLIC int
-ACL_LasRegister(NSErr_t *errp, char *attr_name, LASEvalFunc_t eval_func,
+ACL_LasRegister(NSErr_t *errp, const char *attr_name, LASEvalFunc_t eval_func,
LASFlushFunc_t flush_func)
{
if ((!attr_name) || (!eval_func)) return -1;
10 years, 9 months