summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2010-04-27 11:50:43 -0700
committerNoriko Hosoi <nhosoi@redhat.com>2010-04-27 11:50:43 -0700
commit0501282a9042af77c20b793645a5b241082a08b5 (patch)
treeb3a720350ca913986e25cf72766808c9623b891a
parentb65b3c97847edefe8e9242e5bac294dd13e73234 (diff)
downloadds-0501282a9042af77c20b793645a5b241082a08b5.tar.gz
ds-0501282a9042af77c20b793645a5b241082a08b5.tar.xz
ds-0501282a9042af77c20b793645a5b241082a08b5.zip
574167 - An escaped space at the end of the RDN value is not
handled correctly https://bugzilla.redhat.com/show_bug.cgi?id=574167 Bug Description: If a DN contains "\ " at the end of its RDN, it's be converted to "\20" by slapi_dn_normalize_ext in the add operation. But the following search returns ' ' (not an escaped space). Fix Description: When slapi_dn_normalize_ext was applied to a string which contains "\20", it converted the string to ' '. This fix changes the behaviour so that the string "\20" in DN remains untouched. Also, this patch includes a fix to add a default suffix value with no double quotes in template-suffix-db.ldif.in. We keep double quoted suffix for the backward compatibility.
-rw-r--r--ldap/ldif/template-suffix-db.ldif.in1
-rw-r--r--ldap/servers/slapd/dn.c29
2 files changed, 25 insertions, 5 deletions
diff --git a/ldap/ldif/template-suffix-db.ldif.in b/ldap/ldif/template-suffix-db.ldif.in
index 1b978266..1bcc5c2b 100644
--- a/ldap/ldif/template-suffix-db.ldif.in
+++ b/ldap/ldif/template-suffix-db.ldif.in
@@ -21,6 +21,7 @@ dn: cn="%ds_suffix%",cn=mapping tree,cn=config
objectclass: top
objectclass: extensibleObject
objectclass: nsMappingTree
+cn: %ds_suffix%
cn: "%ds_suffix%"
nsslapd-state: backend
nsslapd-backend: %ds_bename%
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index 743aa361..f30578f6 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -78,6 +78,7 @@ hexchar2int( char c )
}
#define ISBLANK(c) ((c) == ' ')
+#define ISBLANKSTR(s) (((*(s)) == '2') && (*((s)+1) == '0'))
#define ISSPACE(c) (ISBLANK(c) || ((c) == '\n') || ((c) == '\r')) /* XXX 518524 */
#define ISEQUAL(c) ((c) == '=')
@@ -444,6 +445,21 @@ substr_dn_normalize( char *dn, char *end )
return end;
}
+static int
+ISEOV(char *s, char *ends)
+{
+ char *p;
+ int rc = 1;
+ for (p = s; p && *p && p < ends; p++) {
+ if (SEPARATOR(*p)) {
+ return 1;
+ } else if (!ISBLANK(*p)) {
+ return 0; /* not the end of the value */
+ }
+ }
+ return 1;
+}
+
/*
* 1) Escaped NEEDSESCAPE chars (e.g., ',', '<', '=', etc.) are converted to
* ESC HEX HEX (e.g., \2C, \3C, \3D, etc.)
@@ -664,10 +680,13 @@ slapi_dn_normalize_ext(char *src, size_t src_len, char **dest, size_t *dest_len)
s++;
}
}
- } else if (((state == INVALUE1ST) && (s+2 < ends) &&
- LEADNEEDSESCAPESTR(s+1)) ||
- ((state == INVALUE) && (s+2 < ends) &&
- NEEDSESCAPESTR(s+1))) {
+ } else if (((state == INVALUE1ST) &&
+ (s+2 < ends) && LEADNEEDSESCAPESTR(s+1)) ||
+ ((state == INVALUE) &&
+ (((s+2 < ends) && NEEDSESCAPESTR(s+1)) ||
+ (ISEOV(s+3, ends) && ISBLANKSTR(s+1))))) {
+ /* e.g., cn=abc\20 ,... */
+ /* ^ */
if (ISEQUALSTR(s+1)) {
if (NULL == subtypestart) {
/* e.g., cn=a\3Db\2Cc\3Dd */
@@ -933,7 +952,7 @@ bail:
if (*dest != src) {
slapi_ch_free_string(dest);
} else {
- *dest = NULL;
+ *dest = NULL;
}
*dest_len = 0;
} else if (rc > 0) {