Branch '389-ds-base-1.2.11' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/utf8compare.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
New commits:
commit 9760c042717fdaba5af65999629ff87fde46520d
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Sun Mar 9 22:34:52 2014 -0700
Ticket #47734 - Change made in resolving ticket #346 fails on Debian SPARC64
Description: The following change is not generic beyond x86 and
x86_64 architecture. Putting the change into "#if (defined(CPU_x86)
|| defined(CPU_x86_64))".
commit c0151f78509c35250095da6e2785842337963008
Trac Ticket #346 - Slow ldapmodify operation time for large
quantities of multi-valued attribute values
3) In slapi_has8thBit, instead of checking the 8th bit one byte
by one byte, check 4 bytes at one time.
https://fedorahosted.org/389/ticket/47734
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
(cherry picked from commit 1e00913312e165ead2f3a25b6d70f7839115007e)
(cherry picked from commit ba9248d02447dc693114961d9296ecb742a75add)
(cherry picked from commit 450607a75d23984da12c83e785a2e1cfbf49964d)
diff --git a/ldap/servers/slapd/utf8compare.c b/ldap/servers/slapd/utf8compare.c
index e336ccb..d2dd83e 100644
--- a/ldap/servers/slapd/utf8compare.c
+++ b/ldap/servers/slapd/utf8compare.c
@@ -60,6 +60,7 @@ typedef struct sUpperLowerTbl {
int
slapi_has8thBit(unsigned char *s)
{
+#if (defined(CPU_x86) || defined(CPU_x86_64))
#define MY8THBITWIDTH 4 /* sizeof(PRUint32) */
#define MY8THBITFILTER 0x80808080
unsigned char *p, *stail, *ltail;
@@ -73,14 +74,20 @@ slapi_has8thBit(unsigned char *s)
return 1;
}
}
- for (; p < ltail; p++) {
+#undef MY8THBITWIDTH
+#undef MY8THBITFILTER
+ for (; p < ltail; p++)
+#else
+ unsigned char *p, *tail;
+ tail = s + strlen((char *)s);
+ for (p = s; p < tail; p++)
+#endif
+ {
if (0x80 & *p) {
return 1;
}
}
return 0;
-#undef MY8THBITWIDTH
-#undef MY8THBITFILTER
}
/*
10 years, 1 month
Branch '389-ds-base-1.3.1' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/utf8compare.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
New commits:
commit 450607a75d23984da12c83e785a2e1cfbf49964d
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Sun Mar 9 22:34:52 2014 -0700
Ticket #47734 - Change made in resolving ticket #346 fails on Debian SPARC64
Description: The following change is not generic beyond x86 and
x86_64 architecture. Putting the change into "#if (defined(CPU_x86)
|| defined(CPU_x86_64))".
commit c0151f78509c35250095da6e2785842337963008
Trac Ticket #346 - Slow ldapmodify operation time for large
quantities of multi-valued attribute values
3) In slapi_has8thBit, instead of checking the 8th bit one byte
by one byte, check 4 bytes at one time.
https://fedorahosted.org/389/ticket/47734
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
(cherry picked from commit 1e00913312e165ead2f3a25b6d70f7839115007e)
(cherry picked from commit ba9248d02447dc693114961d9296ecb742a75add)
diff --git a/ldap/servers/slapd/utf8compare.c b/ldap/servers/slapd/utf8compare.c
index e336ccb..d2dd83e 100644
--- a/ldap/servers/slapd/utf8compare.c
+++ b/ldap/servers/slapd/utf8compare.c
@@ -60,6 +60,7 @@ typedef struct sUpperLowerTbl {
int
slapi_has8thBit(unsigned char *s)
{
+#if (defined(CPU_x86) || defined(CPU_x86_64))
#define MY8THBITWIDTH 4 /* sizeof(PRUint32) */
#define MY8THBITFILTER 0x80808080
unsigned char *p, *stail, *ltail;
@@ -73,14 +74,20 @@ slapi_has8thBit(unsigned char *s)
return 1;
}
}
- for (; p < ltail; p++) {
+#undef MY8THBITWIDTH
+#undef MY8THBITFILTER
+ for (; p < ltail; p++)
+#else
+ unsigned char *p, *tail;
+ tail = s + strlen((char *)s);
+ for (p = s; p < tail; p++)
+#endif
+ {
if (0x80 & *p) {
return 1;
}
}
return 0;
-#undef MY8THBITWIDTH
-#undef MY8THBITFILTER
}
/*
10 years, 1 month
Branch '389-ds-base-1.3.2' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/utf8compare.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
New commits:
commit ba9248d02447dc693114961d9296ecb742a75add
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Sun Mar 9 22:34:52 2014 -0700
Ticket #47734 - Change made in resolving ticket #346 fails on Debian SPARC64
Description: The following change is not generic beyond x86 and
x86_64 architecture. Putting the change into "#if (defined(CPU_x86)
|| defined(CPU_x86_64))".
commit c0151f78509c35250095da6e2785842337963008
Trac Ticket #346 - Slow ldapmodify operation time for large
quantities of multi-valued attribute values
3) In slapi_has8thBit, instead of checking the 8th bit one byte
by one byte, check 4 bytes at one time.
https://fedorahosted.org/389/ticket/47734
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
(cherry picked from commit 1e00913312e165ead2f3a25b6d70f7839115007e)
diff --git a/ldap/servers/slapd/utf8compare.c b/ldap/servers/slapd/utf8compare.c
index e336ccb..d2dd83e 100644
--- a/ldap/servers/slapd/utf8compare.c
+++ b/ldap/servers/slapd/utf8compare.c
@@ -60,6 +60,7 @@ typedef struct sUpperLowerTbl {
int
slapi_has8thBit(unsigned char *s)
{
+#if (defined(CPU_x86) || defined(CPU_x86_64))
#define MY8THBITWIDTH 4 /* sizeof(PRUint32) */
#define MY8THBITFILTER 0x80808080
unsigned char *p, *stail, *ltail;
@@ -73,14 +74,20 @@ slapi_has8thBit(unsigned char *s)
return 1;
}
}
- for (; p < ltail; p++) {
+#undef MY8THBITWIDTH
+#undef MY8THBITFILTER
+ for (; p < ltail; p++)
+#else
+ unsigned char *p, *tail;
+ tail = s + strlen((char *)s);
+ for (p = s; p < tail; p++)
+#endif
+ {
if (0x80 & *p) {
return 1;
}
}
return 0;
-#undef MY8THBITWIDTH
-#undef MY8THBITFILTER
}
/*
10 years, 1 month
ldap/servers
by Noriko Hosoi
ldap/servers/slapd/utf8compare.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
New commits:
commit 1e00913312e165ead2f3a25b6d70f7839115007e
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Sun Mar 9 22:34:52 2014 -0700
Ticket #47734 - Change made in resolving ticket #346 fails on Debian SPARC64
Description: The following change is not generic beyond x86 and
x86_64 architecture. Putting the change into "#if (defined(CPU_x86)
|| defined(CPU_x86_64))".
commit c0151f78509c35250095da6e2785842337963008
Trac Ticket #346 - Slow ldapmodify operation time for large
quantities of multi-valued attribute values
3) In slapi_has8thBit, instead of checking the 8th bit one byte
by one byte, check 4 bytes at one time.
https://fedorahosted.org/389/ticket/47734
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
diff --git a/ldap/servers/slapd/utf8compare.c b/ldap/servers/slapd/utf8compare.c
index e336ccb..d2dd83e 100644
--- a/ldap/servers/slapd/utf8compare.c
+++ b/ldap/servers/slapd/utf8compare.c
@@ -60,6 +60,7 @@ typedef struct sUpperLowerTbl {
int
slapi_has8thBit(unsigned char *s)
{
+#if (defined(CPU_x86) || defined(CPU_x86_64))
#define MY8THBITWIDTH 4 /* sizeof(PRUint32) */
#define MY8THBITFILTER 0x80808080
unsigned char *p, *stail, *ltail;
@@ -73,14 +74,20 @@ slapi_has8thBit(unsigned char *s)
return 1;
}
}
- for (; p < ltail; p++) {
+#undef MY8THBITWIDTH
+#undef MY8THBITFILTER
+ for (; p < ltail; p++)
+#else
+ unsigned char *p, *tail;
+ tail = s + strlen((char *)s);
+ for (p = s; p < tail; p++)
+#endif
+ {
if (0x80 & *p) {
return 1;
}
}
return 0;
-#undef MY8THBITWIDTH
-#undef MY8THBITFILTER
}
/*
10 years, 1 month
Branch '389-ds-base-1.2.11' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/tools/rsearch/rsearch.c | 11 +++---
ldap/servers/slapd/tools/rsearch/searchthread.c | 40 +++++++++++++++---------
2 files changed, 31 insertions(+), 20 deletions(-)
New commits:
commit 1361c27df349c242277fa294bf025f6af28f0cde
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Mar 11 14:35:53 2014 -0400
Ticket47722 - Fixed filter not correctly identified
Bug Description: Due to an improper table initialization, fixed filters
were not correctly identifed, which lead to incorrect
code execution.
Fix Description: Correct the table initialization. Also, removed all the
fixed buffers for user supplied values. Also increased
the maximum string length to handle a 64bit unsigned integer.
https://fedorahosted.org/389/ticket/47722
Reviewed by: richm(Thanks!)
(cherry picked from commit e118eabf705e7cab724814fb0f5cffa09e6ac8ce)
diff --git a/ldap/servers/slapd/tools/rsearch/rsearch.c b/ldap/servers/slapd/tools/rsearch/rsearch.c
index 1351245..f56da7f 100644
--- a/ldap/servers/slapd/tools/rsearch/rsearch.c
+++ b/ldap/servers/slapd/tools/rsearch/rsearch.c
@@ -406,12 +406,13 @@ int main(int argc, char** argv)
PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 0);
- ntable = nt_new(0);
+
if (nameFile) {
- if (!nt_load(ntable, nameFile)) {
- printf("Failed to read name table\n");
- exit(1);
- }
+ ntable = nt_new(0);
+ if (!nt_load(ntable, nameFile)) {
+ printf("Failed to read name table\n");
+ exit(1);
+ }
}
attrTable = nt_new(0);
diff --git a/ldap/servers/slapd/tools/rsearch/searchthread.c b/ldap/servers/slapd/tools/rsearch/searchthread.c
index e92209f..9f1d127 100644
--- a/ldap/servers/slapd/tools/rsearch/searchthread.c
+++ b/ldap/servers/slapd/tools/rsearch/searchthread.c
@@ -285,20 +285,18 @@ static int st_bind(SearchThread *st)
return 0;
}
} else if (uid) {
- char filterBuffer[100];
- char *pFilter;
- char *filterTemplate = (uidFilter) ? uidFilter : "(uid=%s)";
+ char *filterBuffer = NULL;
+ char *filterTemplate = (uidFilter) ? uidFilter : "(uid=%s)";
struct timeval timeout;
int scope = LDAP_SCOPE_SUBTREE, attrsOnly = 0;
LDAPMessage *result;
int retry = 0;
- pFilter = filterBuffer;
- sprintf(filterBuffer, filterTemplate, uid);
+ filterBuffer = PR_smprintf(filterTemplate, uid);
timeout.tv_sec = 3600;
timeout.tv_usec = 0;
while (1) {
- int ret = ldap_search_ext_s(st->ld2, suffix, scope, pFilter,
+ int ret = ldap_search_ext_s(st->ld2, suffix, scope, filterBuffer,
NULL, attrsOnly, NULL, NULL,
&timeout, -1, &result);
if (LDAP_SUCCESS == ret) {
@@ -309,9 +307,11 @@ static int st_bind(SearchThread *st)
} else {
fprintf(stderr, "T%d: failed to search 1, error=0x%x\n",
st->id, ret);
+ PR_smprintf_free(filterBuffer);
return 0;
}
}
+ PR_smprintf_free(filterBuffer);
dn = ldap_get_dn(st->ld2, result);
if (0 == st_bind_core(st, &(st->ld), dn, upw)) {
@@ -366,7 +366,7 @@ static void st_unbind(SearchThread *st)
static int st_search(SearchThread *st)
{
- char filterBuffer[100];
+ char *filterBuffer = NULL;
char *pFilter;
struct timeval timeout;
struct timeval *timeoutp;
@@ -377,7 +377,7 @@ static int st_search(SearchThread *st)
scope = myScope;
if (ntable || numeric) {
char *s = NULL;
- char num[8];
+ char num[22]; /* string length of unsigned 64 bit integer + 1 */
if (! numeric) {
do {
@@ -387,7 +387,7 @@ static int st_search(SearchThread *st)
sprintf(num, "%d", get_large_random_number() % numeric);
s = num;
}
- sprintf(filterBuffer, "%s%s", filter, s ? s : "");
+ filterBuffer = PR_smprintf("%s%s",filter, s ? s : "");
pFilter = filterBuffer;
} else {
pFilter = filter;
@@ -411,6 +411,10 @@ static int st_search(SearchThread *st)
st->id, ret);
}
ldap_msgfree(result);
+ if(filterBuffer){
+ PR_smprintf_free(filterBuffer);
+ }
+
return ret;
}
@@ -431,7 +435,7 @@ static int st_modify_nonidx(SearchThread *st)
int e;
int rval;
char *dn = NULL;
- char description[256];
+ char *description = NULL;
char *description_values[2];
/* Decide what entry to modify, for this we need a table */
@@ -446,7 +450,7 @@ static int st_modify_nonidx(SearchThread *st)
} while (e < 0);
dn = sdt_dn_get(sdattable, e);
- sprintf(description, "%s modified at %lu", dn, time(NULL));
+ description = PR_smprintf("%s modified at %lu", dn, time(NULL));
description_values[0] = description;
description_values[1] = NULL;
@@ -462,6 +466,8 @@ static int st_modify_nonidx(SearchThread *st)
fprintf(stderr, "T%d: Failed to modify error=0x%x\n", st->id, rval);
fprintf(stderr, "dn: %s\n", dn);
}
+ PR_smprintf_free(description);
+
return rval;
}
@@ -516,7 +522,7 @@ static int st_compare(SearchThread *st)
int e;
char *dn = NULL;
char *uid = NULL;
- char uid0[100];
+ char *uidFalse = NULL;
struct berval bvvalue = {0, NULL};
/* Decide what entry to modify, for this we need a table */
@@ -535,9 +541,9 @@ static int st_compare(SearchThread *st)
compare_true = ( (rand() % 5) < 2 );
if (!compare_true) {
- strcpy(uid0, uid);
- uid0[0] = '@'; /* make it not matched */
- uid = uid0;
+ /* modify the uid to make it fail the comparison */
+ uidFalse = PR_smprintf("@%s",uid);
+ uid = uidFalse;
}
bvvalue.bv_val = uid;
bvvalue.bv_len = uid ? strlen(uid) : 0;
@@ -550,6 +556,10 @@ static int st_compare(SearchThread *st)
st->id, rval, correct_answer);
fprintf(stderr, "dn: %s, uid: %s\n", dn, uid);
}
+ if(uidFalse){
+ PR_smprintf_free(uidFalse);
+ }
+
return rval;
}
10 years, 1 month
Branch '389-ds-base-1.3.0' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/tools/rsearch/rsearch.c | 11 +++---
ldap/servers/slapd/tools/rsearch/searchthread.c | 40 +++++++++++++++---------
2 files changed, 31 insertions(+), 20 deletions(-)
New commits:
commit e118eabf705e7cab724814fb0f5cffa09e6ac8ce
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Mar 11 14:35:53 2014 -0400
Ticket47722 - Fixed filter not correctly identified
Bug Description: Due to an improper table initialization, fixed filters
were not correctly identifed, which lead to incorrect
code execution.
Fix Description: Correct the table initialization. Also, removed all the
fixed buffers for user supplied values. Also increased
the maximum string length to handle a 64bit unsigned integer.
https://fedorahosted.org/389/ticket/47722
Reviewed by: richm(Thanks!)
diff --git a/ldap/servers/slapd/tools/rsearch/rsearch.c b/ldap/servers/slapd/tools/rsearch/rsearch.c
index 1351245..f56da7f 100644
--- a/ldap/servers/slapd/tools/rsearch/rsearch.c
+++ b/ldap/servers/slapd/tools/rsearch/rsearch.c
@@ -406,12 +406,13 @@ int main(int argc, char** argv)
PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 0);
- ntable = nt_new(0);
+
if (nameFile) {
- if (!nt_load(ntable, nameFile)) {
- printf("Failed to read name table\n");
- exit(1);
- }
+ ntable = nt_new(0);
+ if (!nt_load(ntable, nameFile)) {
+ printf("Failed to read name table\n");
+ exit(1);
+ }
}
attrTable = nt_new(0);
diff --git a/ldap/servers/slapd/tools/rsearch/searchthread.c b/ldap/servers/slapd/tools/rsearch/searchthread.c
index e92209f..9f1d127 100644
--- a/ldap/servers/slapd/tools/rsearch/searchthread.c
+++ b/ldap/servers/slapd/tools/rsearch/searchthread.c
@@ -285,20 +285,18 @@ static int st_bind(SearchThread *st)
return 0;
}
} else if (uid) {
- char filterBuffer[100];
- char *pFilter;
- char *filterTemplate = (uidFilter) ? uidFilter : "(uid=%s)";
+ char *filterBuffer = NULL;
+ char *filterTemplate = (uidFilter) ? uidFilter : "(uid=%s)";
struct timeval timeout;
int scope = LDAP_SCOPE_SUBTREE, attrsOnly = 0;
LDAPMessage *result;
int retry = 0;
- pFilter = filterBuffer;
- sprintf(filterBuffer, filterTemplate, uid);
+ filterBuffer = PR_smprintf(filterTemplate, uid);
timeout.tv_sec = 3600;
timeout.tv_usec = 0;
while (1) {
- int ret = ldap_search_ext_s(st->ld2, suffix, scope, pFilter,
+ int ret = ldap_search_ext_s(st->ld2, suffix, scope, filterBuffer,
NULL, attrsOnly, NULL, NULL,
&timeout, -1, &result);
if (LDAP_SUCCESS == ret) {
@@ -309,9 +307,11 @@ static int st_bind(SearchThread *st)
} else {
fprintf(stderr, "T%d: failed to search 1, error=0x%x\n",
st->id, ret);
+ PR_smprintf_free(filterBuffer);
return 0;
}
}
+ PR_smprintf_free(filterBuffer);
dn = ldap_get_dn(st->ld2, result);
if (0 == st_bind_core(st, &(st->ld), dn, upw)) {
@@ -366,7 +366,7 @@ static void st_unbind(SearchThread *st)
static int st_search(SearchThread *st)
{
- char filterBuffer[100];
+ char *filterBuffer = NULL;
char *pFilter;
struct timeval timeout;
struct timeval *timeoutp;
@@ -377,7 +377,7 @@ static int st_search(SearchThread *st)
scope = myScope;
if (ntable || numeric) {
char *s = NULL;
- char num[8];
+ char num[22]; /* string length of unsigned 64 bit integer + 1 */
if (! numeric) {
do {
@@ -387,7 +387,7 @@ static int st_search(SearchThread *st)
sprintf(num, "%d", get_large_random_number() % numeric);
s = num;
}
- sprintf(filterBuffer, "%s%s", filter, s ? s : "");
+ filterBuffer = PR_smprintf("%s%s",filter, s ? s : "");
pFilter = filterBuffer;
} else {
pFilter = filter;
@@ -411,6 +411,10 @@ static int st_search(SearchThread *st)
st->id, ret);
}
ldap_msgfree(result);
+ if(filterBuffer){
+ PR_smprintf_free(filterBuffer);
+ }
+
return ret;
}
@@ -431,7 +435,7 @@ static int st_modify_nonidx(SearchThread *st)
int e;
int rval;
char *dn = NULL;
- char description[256];
+ char *description = NULL;
char *description_values[2];
/* Decide what entry to modify, for this we need a table */
@@ -446,7 +450,7 @@ static int st_modify_nonidx(SearchThread *st)
} while (e < 0);
dn = sdt_dn_get(sdattable, e);
- sprintf(description, "%s modified at %lu", dn, time(NULL));
+ description = PR_smprintf("%s modified at %lu", dn, time(NULL));
description_values[0] = description;
description_values[1] = NULL;
@@ -462,6 +466,8 @@ static int st_modify_nonidx(SearchThread *st)
fprintf(stderr, "T%d: Failed to modify error=0x%x\n", st->id, rval);
fprintf(stderr, "dn: %s\n", dn);
}
+ PR_smprintf_free(description);
+
return rval;
}
@@ -516,7 +522,7 @@ static int st_compare(SearchThread *st)
int e;
char *dn = NULL;
char *uid = NULL;
- char uid0[100];
+ char *uidFalse = NULL;
struct berval bvvalue = {0, NULL};
/* Decide what entry to modify, for this we need a table */
@@ -535,9 +541,9 @@ static int st_compare(SearchThread *st)
compare_true = ( (rand() % 5) < 2 );
if (!compare_true) {
- strcpy(uid0, uid);
- uid0[0] = '@'; /* make it not matched */
- uid = uid0;
+ /* modify the uid to make it fail the comparison */
+ uidFalse = PR_smprintf("@%s",uid);
+ uid = uidFalse;
}
bvvalue.bv_val = uid;
bvvalue.bv_len = uid ? strlen(uid) : 0;
@@ -550,6 +556,10 @@ static int st_compare(SearchThread *st)
st->id, rval, correct_answer);
fprintf(stderr, "dn: %s, uid: %s\n", dn, uid);
}
+ if(uidFalse){
+ PR_smprintf_free(uidFalse);
+ }
+
return rval;
}
10 years, 1 month
Branch '389-ds-base-1.3.1' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/tools/rsearch/rsearch.c | 11 +++---
ldap/servers/slapd/tools/rsearch/searchthread.c | 40 +++++++++++++++---------
2 files changed, 31 insertions(+), 20 deletions(-)
New commits:
commit a433ed7d6a081f773b58682745ce85b02e69a5d8
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Mar 11 14:35:53 2014 -0400
Ticket47722 - Fixed filter not correctly identified
Bug Description: Due to an improper table initialization, fixed filters
were not correctly identifed, which lead to incorrect
code execution.
Fix Description: Correct the table initialization. Also, removed all the
fixed buffers for user supplied values. Also increased
the maximum string length to handle a 64bit unsigned integer.
https://fedorahosted.org/389/ticket/47722
Reviewed by: richm(Thanks!)
(cherry picked from commit 2ec0cdb295e145bff60d020708339c77b10a9367)
diff --git a/ldap/servers/slapd/tools/rsearch/rsearch.c b/ldap/servers/slapd/tools/rsearch/rsearch.c
index 1351245..f56da7f 100644
--- a/ldap/servers/slapd/tools/rsearch/rsearch.c
+++ b/ldap/servers/slapd/tools/rsearch/rsearch.c
@@ -406,12 +406,13 @@ int main(int argc, char** argv)
PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 0);
- ntable = nt_new(0);
+
if (nameFile) {
- if (!nt_load(ntable, nameFile)) {
- printf("Failed to read name table\n");
- exit(1);
- }
+ ntable = nt_new(0);
+ if (!nt_load(ntable, nameFile)) {
+ printf("Failed to read name table\n");
+ exit(1);
+ }
}
attrTable = nt_new(0);
diff --git a/ldap/servers/slapd/tools/rsearch/searchthread.c b/ldap/servers/slapd/tools/rsearch/searchthread.c
index e999b1e..9f1d127 100644
--- a/ldap/servers/slapd/tools/rsearch/searchthread.c
+++ b/ldap/servers/slapd/tools/rsearch/searchthread.c
@@ -285,20 +285,18 @@ static int st_bind(SearchThread *st)
return 0;
}
} else if (uid) {
- char filterBuffer[4096];
- char *pFilter;
- char *filterTemplate = (uidFilter) ? uidFilter : "(uid=%s)";
+ char *filterBuffer = NULL;
+ char *filterTemplate = (uidFilter) ? uidFilter : "(uid=%s)";
struct timeval timeout;
int scope = LDAP_SCOPE_SUBTREE, attrsOnly = 0;
LDAPMessage *result;
int retry = 0;
- pFilter = filterBuffer;
- sprintf(filterBuffer, filterTemplate, uid);
+ filterBuffer = PR_smprintf(filterTemplate, uid);
timeout.tv_sec = 3600;
timeout.tv_usec = 0;
while (1) {
- int ret = ldap_search_ext_s(st->ld2, suffix, scope, pFilter,
+ int ret = ldap_search_ext_s(st->ld2, suffix, scope, filterBuffer,
NULL, attrsOnly, NULL, NULL,
&timeout, -1, &result);
if (LDAP_SUCCESS == ret) {
@@ -309,9 +307,11 @@ static int st_bind(SearchThread *st)
} else {
fprintf(stderr, "T%d: failed to search 1, error=0x%x\n",
st->id, ret);
+ PR_smprintf_free(filterBuffer);
return 0;
}
}
+ PR_smprintf_free(filterBuffer);
dn = ldap_get_dn(st->ld2, result);
if (0 == st_bind_core(st, &(st->ld), dn, upw)) {
@@ -366,7 +366,7 @@ static void st_unbind(SearchThread *st)
static int st_search(SearchThread *st)
{
- char filterBuffer[100];
+ char *filterBuffer = NULL;
char *pFilter;
struct timeval timeout;
struct timeval *timeoutp;
@@ -377,7 +377,7 @@ static int st_search(SearchThread *st)
scope = myScope;
if (ntable || numeric) {
char *s = NULL;
- char num[8];
+ char num[22]; /* string length of unsigned 64 bit integer + 1 */
if (! numeric) {
do {
@@ -387,7 +387,7 @@ static int st_search(SearchThread *st)
sprintf(num, "%d", get_large_random_number() % numeric);
s = num;
}
- sprintf(filterBuffer, "%s%s", filter, s ? s : "");
+ filterBuffer = PR_smprintf("%s%s",filter, s ? s : "");
pFilter = filterBuffer;
} else {
pFilter = filter;
@@ -411,6 +411,10 @@ static int st_search(SearchThread *st)
st->id, ret);
}
ldap_msgfree(result);
+ if(filterBuffer){
+ PR_smprintf_free(filterBuffer);
+ }
+
return ret;
}
@@ -431,7 +435,7 @@ static int st_modify_nonidx(SearchThread *st)
int e;
int rval;
char *dn = NULL;
- char description[256];
+ char *description = NULL;
char *description_values[2];
/* Decide what entry to modify, for this we need a table */
@@ -446,7 +450,7 @@ static int st_modify_nonidx(SearchThread *st)
} while (e < 0);
dn = sdt_dn_get(sdattable, e);
- sprintf(description, "%s modified at %lu", dn, time(NULL));
+ description = PR_smprintf("%s modified at %lu", dn, time(NULL));
description_values[0] = description;
description_values[1] = NULL;
@@ -462,6 +466,8 @@ static int st_modify_nonidx(SearchThread *st)
fprintf(stderr, "T%d: Failed to modify error=0x%x\n", st->id, rval);
fprintf(stderr, "dn: %s\n", dn);
}
+ PR_smprintf_free(description);
+
return rval;
}
@@ -516,7 +522,7 @@ static int st_compare(SearchThread *st)
int e;
char *dn = NULL;
char *uid = NULL;
- char uid0[100];
+ char *uidFalse = NULL;
struct berval bvvalue = {0, NULL};
/* Decide what entry to modify, for this we need a table */
@@ -535,9 +541,9 @@ static int st_compare(SearchThread *st)
compare_true = ( (rand() % 5) < 2 );
if (!compare_true) {
- strcpy(uid0, uid);
- uid0[0] = '@'; /* make it not matched */
- uid = uid0;
+ /* modify the uid to make it fail the comparison */
+ uidFalse = PR_smprintf("@%s",uid);
+ uid = uidFalse;
}
bvvalue.bv_val = uid;
bvvalue.bv_len = uid ? strlen(uid) : 0;
@@ -550,6 +556,10 @@ static int st_compare(SearchThread *st)
st->id, rval, correct_answer);
fprintf(stderr, "dn: %s, uid: %s\n", dn, uid);
}
+ if(uidFalse){
+ PR_smprintf_free(uidFalse);
+ }
+
return rval;
}
10 years, 1 month
Branch '389-ds-base-1.3.2' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/tools/rsearch/rsearch.c | 11 +++---
ldap/servers/slapd/tools/rsearch/searchthread.c | 40 +++++++++++++++---------
2 files changed, 31 insertions(+), 20 deletions(-)
New commits:
commit dee6ed16d5ba4c2ffeebe047cb69b9501f77870b
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Mar 11 14:35:53 2014 -0400
Ticket47722 - Fixed filter not correctly identified
Bug Description: Due to an improper table initialization, fixed filters
were not correctly identifed, which lead to incorrect
code execution.
Fix Description: Correct the table initialization. Also, removed all the
fixed buffers for user supplied values. Also increased
the maximum string length to handle a 64bit unsigned integer.
https://fedorahosted.org/389/ticket/47722
Reviewed by: richm(Thanks!)
(cherry picked from commit 2ec0cdb295e145bff60d020708339c77b10a9367)
diff --git a/ldap/servers/slapd/tools/rsearch/rsearch.c b/ldap/servers/slapd/tools/rsearch/rsearch.c
index 1351245..f56da7f 100644
--- a/ldap/servers/slapd/tools/rsearch/rsearch.c
+++ b/ldap/servers/slapd/tools/rsearch/rsearch.c
@@ -406,12 +406,13 @@ int main(int argc, char** argv)
PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 0);
- ntable = nt_new(0);
+
if (nameFile) {
- if (!nt_load(ntable, nameFile)) {
- printf("Failed to read name table\n");
- exit(1);
- }
+ ntable = nt_new(0);
+ if (!nt_load(ntable, nameFile)) {
+ printf("Failed to read name table\n");
+ exit(1);
+ }
}
attrTable = nt_new(0);
diff --git a/ldap/servers/slapd/tools/rsearch/searchthread.c b/ldap/servers/slapd/tools/rsearch/searchthread.c
index e999b1e..9f1d127 100644
--- a/ldap/servers/slapd/tools/rsearch/searchthread.c
+++ b/ldap/servers/slapd/tools/rsearch/searchthread.c
@@ -285,20 +285,18 @@ static int st_bind(SearchThread *st)
return 0;
}
} else if (uid) {
- char filterBuffer[4096];
- char *pFilter;
- char *filterTemplate = (uidFilter) ? uidFilter : "(uid=%s)";
+ char *filterBuffer = NULL;
+ char *filterTemplate = (uidFilter) ? uidFilter : "(uid=%s)";
struct timeval timeout;
int scope = LDAP_SCOPE_SUBTREE, attrsOnly = 0;
LDAPMessage *result;
int retry = 0;
- pFilter = filterBuffer;
- sprintf(filterBuffer, filterTemplate, uid);
+ filterBuffer = PR_smprintf(filterTemplate, uid);
timeout.tv_sec = 3600;
timeout.tv_usec = 0;
while (1) {
- int ret = ldap_search_ext_s(st->ld2, suffix, scope, pFilter,
+ int ret = ldap_search_ext_s(st->ld2, suffix, scope, filterBuffer,
NULL, attrsOnly, NULL, NULL,
&timeout, -1, &result);
if (LDAP_SUCCESS == ret) {
@@ -309,9 +307,11 @@ static int st_bind(SearchThread *st)
} else {
fprintf(stderr, "T%d: failed to search 1, error=0x%x\n",
st->id, ret);
+ PR_smprintf_free(filterBuffer);
return 0;
}
}
+ PR_smprintf_free(filterBuffer);
dn = ldap_get_dn(st->ld2, result);
if (0 == st_bind_core(st, &(st->ld), dn, upw)) {
@@ -366,7 +366,7 @@ static void st_unbind(SearchThread *st)
static int st_search(SearchThread *st)
{
- char filterBuffer[100];
+ char *filterBuffer = NULL;
char *pFilter;
struct timeval timeout;
struct timeval *timeoutp;
@@ -377,7 +377,7 @@ static int st_search(SearchThread *st)
scope = myScope;
if (ntable || numeric) {
char *s = NULL;
- char num[8];
+ char num[22]; /* string length of unsigned 64 bit integer + 1 */
if (! numeric) {
do {
@@ -387,7 +387,7 @@ static int st_search(SearchThread *st)
sprintf(num, "%d", get_large_random_number() % numeric);
s = num;
}
- sprintf(filterBuffer, "%s%s", filter, s ? s : "");
+ filterBuffer = PR_smprintf("%s%s",filter, s ? s : "");
pFilter = filterBuffer;
} else {
pFilter = filter;
@@ -411,6 +411,10 @@ static int st_search(SearchThread *st)
st->id, ret);
}
ldap_msgfree(result);
+ if(filterBuffer){
+ PR_smprintf_free(filterBuffer);
+ }
+
return ret;
}
@@ -431,7 +435,7 @@ static int st_modify_nonidx(SearchThread *st)
int e;
int rval;
char *dn = NULL;
- char description[256];
+ char *description = NULL;
char *description_values[2];
/* Decide what entry to modify, for this we need a table */
@@ -446,7 +450,7 @@ static int st_modify_nonidx(SearchThread *st)
} while (e < 0);
dn = sdt_dn_get(sdattable, e);
- sprintf(description, "%s modified at %lu", dn, time(NULL));
+ description = PR_smprintf("%s modified at %lu", dn, time(NULL));
description_values[0] = description;
description_values[1] = NULL;
@@ -462,6 +466,8 @@ static int st_modify_nonidx(SearchThread *st)
fprintf(stderr, "T%d: Failed to modify error=0x%x\n", st->id, rval);
fprintf(stderr, "dn: %s\n", dn);
}
+ PR_smprintf_free(description);
+
return rval;
}
@@ -516,7 +522,7 @@ static int st_compare(SearchThread *st)
int e;
char *dn = NULL;
char *uid = NULL;
- char uid0[100];
+ char *uidFalse = NULL;
struct berval bvvalue = {0, NULL};
/* Decide what entry to modify, for this we need a table */
@@ -535,9 +541,9 @@ static int st_compare(SearchThread *st)
compare_true = ( (rand() % 5) < 2 );
if (!compare_true) {
- strcpy(uid0, uid);
- uid0[0] = '@'; /* make it not matched */
- uid = uid0;
+ /* modify the uid to make it fail the comparison */
+ uidFalse = PR_smprintf("@%s",uid);
+ uid = uidFalse;
}
bvvalue.bv_val = uid;
bvvalue.bv_len = uid ? strlen(uid) : 0;
@@ -550,6 +556,10 @@ static int st_compare(SearchThread *st)
st->id, rval, correct_answer);
fprintf(stderr, "dn: %s, uid: %s\n", dn, uid);
}
+ if(uidFalse){
+ PR_smprintf_free(uidFalse);
+ }
+
return rval;
}
10 years, 1 month
ldap/servers
by Mark Reynolds
ldap/servers/slapd/tools/rsearch/rsearch.c | 11 +++---
ldap/servers/slapd/tools/rsearch/searchthread.c | 40 +++++++++++++++---------
2 files changed, 31 insertions(+), 20 deletions(-)
New commits:
commit 2ec0cdb295e145bff60d020708339c77b10a9367
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Mar 11 14:35:53 2014 -0400
Ticket47722 - Fixed filter not correctly identified
Bug Description: Due to an improper table initialization, fixed filters
were not correctly identifed, which lead to incorrect
code execution.
Fix Description: Correct the table initialization. Also, removed all the
fixed buffers for user supplied values. Also increased
the maximum string length to handle a 64bit unsigned integer.
https://fedorahosted.org/389/ticket/47722
Reviewed by: richm(Thanks!)
diff --git a/ldap/servers/slapd/tools/rsearch/rsearch.c b/ldap/servers/slapd/tools/rsearch/rsearch.c
index 1351245..f56da7f 100644
--- a/ldap/servers/slapd/tools/rsearch/rsearch.c
+++ b/ldap/servers/slapd/tools/rsearch/rsearch.c
@@ -406,12 +406,13 @@ int main(int argc, char** argv)
PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 0);
- ntable = nt_new(0);
+
if (nameFile) {
- if (!nt_load(ntable, nameFile)) {
- printf("Failed to read name table\n");
- exit(1);
- }
+ ntable = nt_new(0);
+ if (!nt_load(ntable, nameFile)) {
+ printf("Failed to read name table\n");
+ exit(1);
+ }
}
attrTable = nt_new(0);
diff --git a/ldap/servers/slapd/tools/rsearch/searchthread.c b/ldap/servers/slapd/tools/rsearch/searchthread.c
index e999b1e..9f1d127 100644
--- a/ldap/servers/slapd/tools/rsearch/searchthread.c
+++ b/ldap/servers/slapd/tools/rsearch/searchthread.c
@@ -285,20 +285,18 @@ static int st_bind(SearchThread *st)
return 0;
}
} else if (uid) {
- char filterBuffer[4096];
- char *pFilter;
- char *filterTemplate = (uidFilter) ? uidFilter : "(uid=%s)";
+ char *filterBuffer = NULL;
+ char *filterTemplate = (uidFilter) ? uidFilter : "(uid=%s)";
struct timeval timeout;
int scope = LDAP_SCOPE_SUBTREE, attrsOnly = 0;
LDAPMessage *result;
int retry = 0;
- pFilter = filterBuffer;
- sprintf(filterBuffer, filterTemplate, uid);
+ filterBuffer = PR_smprintf(filterTemplate, uid);
timeout.tv_sec = 3600;
timeout.tv_usec = 0;
while (1) {
- int ret = ldap_search_ext_s(st->ld2, suffix, scope, pFilter,
+ int ret = ldap_search_ext_s(st->ld2, suffix, scope, filterBuffer,
NULL, attrsOnly, NULL, NULL,
&timeout, -1, &result);
if (LDAP_SUCCESS == ret) {
@@ -309,9 +307,11 @@ static int st_bind(SearchThread *st)
} else {
fprintf(stderr, "T%d: failed to search 1, error=0x%x\n",
st->id, ret);
+ PR_smprintf_free(filterBuffer);
return 0;
}
}
+ PR_smprintf_free(filterBuffer);
dn = ldap_get_dn(st->ld2, result);
if (0 == st_bind_core(st, &(st->ld), dn, upw)) {
@@ -366,7 +366,7 @@ static void st_unbind(SearchThread *st)
static int st_search(SearchThread *st)
{
- char filterBuffer[100];
+ char *filterBuffer = NULL;
char *pFilter;
struct timeval timeout;
struct timeval *timeoutp;
@@ -377,7 +377,7 @@ static int st_search(SearchThread *st)
scope = myScope;
if (ntable || numeric) {
char *s = NULL;
- char num[8];
+ char num[22]; /* string length of unsigned 64 bit integer + 1 */
if (! numeric) {
do {
@@ -387,7 +387,7 @@ static int st_search(SearchThread *st)
sprintf(num, "%d", get_large_random_number() % numeric);
s = num;
}
- sprintf(filterBuffer, "%s%s", filter, s ? s : "");
+ filterBuffer = PR_smprintf("%s%s",filter, s ? s : "");
pFilter = filterBuffer;
} else {
pFilter = filter;
@@ -411,6 +411,10 @@ static int st_search(SearchThread *st)
st->id, ret);
}
ldap_msgfree(result);
+ if(filterBuffer){
+ PR_smprintf_free(filterBuffer);
+ }
+
return ret;
}
@@ -431,7 +435,7 @@ static int st_modify_nonidx(SearchThread *st)
int e;
int rval;
char *dn = NULL;
- char description[256];
+ char *description = NULL;
char *description_values[2];
/* Decide what entry to modify, for this we need a table */
@@ -446,7 +450,7 @@ static int st_modify_nonidx(SearchThread *st)
} while (e < 0);
dn = sdt_dn_get(sdattable, e);
- sprintf(description, "%s modified at %lu", dn, time(NULL));
+ description = PR_smprintf("%s modified at %lu", dn, time(NULL));
description_values[0] = description;
description_values[1] = NULL;
@@ -462,6 +466,8 @@ static int st_modify_nonidx(SearchThread *st)
fprintf(stderr, "T%d: Failed to modify error=0x%x\n", st->id, rval);
fprintf(stderr, "dn: %s\n", dn);
}
+ PR_smprintf_free(description);
+
return rval;
}
@@ -516,7 +522,7 @@ static int st_compare(SearchThread *st)
int e;
char *dn = NULL;
char *uid = NULL;
- char uid0[100];
+ char *uidFalse = NULL;
struct berval bvvalue = {0, NULL};
/* Decide what entry to modify, for this we need a table */
@@ -535,9 +541,9 @@ static int st_compare(SearchThread *st)
compare_true = ( (rand() % 5) < 2 );
if (!compare_true) {
- strcpy(uid0, uid);
- uid0[0] = '@'; /* make it not matched */
- uid = uid0;
+ /* modify the uid to make it fail the comparison */
+ uidFalse = PR_smprintf("@%s",uid);
+ uid = uidFalse;
}
bvvalue.bv_val = uid;
bvvalue.bv_len = uid ? strlen(uid) : 0;
@@ -550,6 +556,10 @@ static int st_compare(SearchThread *st)
st->id, rval, correct_answer);
fprintf(stderr, "dn: %s, uid: %s\n", dn, uid);
}
+ if(uidFalse){
+ PR_smprintf_free(uidFalse);
+ }
+
return rval;
}
10 years, 1 month
Branch '389-ds-base-1.2.11' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/tools/rsearch/searchthread.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 0aa38a22b02b3e6ad486711424dc74f2d09662c3
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Mar 11 11:17:53 2014 -0400
Ticket 47722 - rsearch filter error on any search filter
Bug Description: A NULL gets incorrectly added to the search filter, which
creates an invalid filter.
Fix Description: Do not add a NULL character to the search filter.
Original fix submitted by nkinder(Thanks!)
https://fedorahosted.org/389/ticket/47722
Reviewed by: nhoosi(Thanks!)
(cherry picked from commit 8afcf90b0d9d6599144bb1666ca79cef9e91b3ef)
diff --git a/ldap/servers/slapd/tools/rsearch/searchthread.c b/ldap/servers/slapd/tools/rsearch/searchthread.c
index 8a74d58..e92209f 100644
--- a/ldap/servers/slapd/tools/rsearch/searchthread.c
+++ b/ldap/servers/slapd/tools/rsearch/searchthread.c
@@ -387,7 +387,7 @@ static int st_search(SearchThread *st)
sprintf(num, "%d", get_large_random_number() % numeric);
s = num;
}
- sprintf(filterBuffer, "%s%s", filter, s);
+ sprintf(filterBuffer, "%s%s", filter, s ? s : "");
pFilter = filterBuffer;
} else {
pFilter = filter;
10 years, 1 month