summaryrefslogtreecommitdiffstats
path: root/ldap/servers/slapd/ava.c
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@redhat.com>2009-01-06 22:50:30 +0000
committerNoriko Hosoi <nhosoi@redhat.com>2009-01-06 22:50:30 +0000
commit3d9bdf5a15fcb3df6822aa9054e70d80ced07087 (patch)
treedd47111eca4e992f8722493adea232f6d1635722 /ldap/servers/slapd/ava.c
parentb549731422b37541cfd007d7ec09e9b1482413cf (diff)
downloadds-3d9bdf5a15fcb3df6822aa9054e70d80ced07087.tar.gz
ds-3d9bdf5a15fcb3df6822aa9054e70d80ced07087.tar.xz
ds-3d9bdf5a15fcb3df6822aa9054e70d80ced07087.zip
Resolves: #438139
Summary: DN with antislash('\') rename (modrdn) problem Problem description: Unescape codes in the DS (strcpy_special_undo in ava.c and strcpy_unescape_dnvalue in dn.c) were "unescaping" more than the escape code (e.g., escape_dn_value in NET LDAP) does escaping. The test string 'BeforeSlash\AfterSlash' fortunately/unfortunately contains '\Af', which is considered '\##' (where # is hex number) by the DS unescape functions even though it was not meant to be escaped. As long as using UTF-8, there is no chance for the server to receive "\af". Change description: 1) There were identical static functions: strcpy_special_undo (ava.c) and strcpy_special_undo (dn.c). Merged them to strcpy_unescape_value and put it in util.c. 2) In the unescape/normalize functions for dn (strcpy_unescape_value in util.c and substr_dn_normalize in dn.c), added a check for the first hex number in '\##'. If the 8th bit is on, we don't do unescaping but store it as is since the unescaped character is not UTF-8. 3) If 2 consecutive '\'s are passed to the unescape/normalize functions, keep one of them.
Diffstat (limited to 'ldap/servers/slapd/ava.c')
-rw-r--r--ldap/servers/slapd/ava.c66
1 files changed, 1 insertions, 65 deletions
diff --git a/ldap/servers/slapd/ava.c b/ldap/servers/slapd/ava.c
index e1ffff1a..78dc456d 100644
--- a/ldap/servers/slapd/ava.c
+++ b/ldap/servers/slapd/ava.c
@@ -96,73 +96,9 @@ rdn2ava(
*s++ = '\0';
ava->ava_type = rdn;
- strcpy_special_undo( s, s );
+ strcpy_unescape_value( s, s );
ava->ava_value.bv_val = s;
ava->ava_value.bv_len = strlen( s );
return( 0 );
}
-
-/*
-** This function takes a quoted attribute value of the form "abc",
-** and strips off the enclosing quotes. It also deals with quoted
-** characters by removing the preceeding '\' character.
-**
-*/
-static void
-strcpy_special_undo( char *d, const char *s )
-{
- const char *end = s + strlen(s);
- for ( ; s < end && *s; s++ )
- {
- switch ( *s )
- {
- case '"':
- break;
- case '\\':
- {
- /*
- * The '\' could be escaping a single character, ie \"
- * or could be escaping a hex byte, ie \01
- */
- int singlecharacter= 1;
- if ( s+2 < end )
- {
- int n = hexchar2int( s[1] );
- if ( n >= 0 )
- {
- int n2 = hexchar2int( s[2] );
- if ( n2 >= 0 )
- {
- singlecharacter= 0;
- n = (n << 4) + n2;
- if (n == 0)
- {
- /* don't change \00 */
- *d++ = *++s;
- *d++ = *++s;
- }
- else
- {
- /* change \xx to a single char */
- ++s;
- *(unsigned char*)(s+1) = n;
- }
- }
- }
- }
- if(singlecharacter)
- {
- s++;
- *d++ = *s;
- }
- break;
- }
- default:
- *d++ = *s;
- break;
- }
- }
- *d = '\0';
-}
-