summaryrefslogtreecommitdiffstats
path: root/source/lib/ldap_escape.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2007-03-20 16:56:16 +0000
committerGerald Carter <jerry@samba.org>2007-03-20 16:56:16 +0000
commit651d5a89c59c107c05e789358624058e16af1b66 (patch)
treedfd29754255ea87b30eb16a06c505e42f98b9be3 /source/lib/ldap_escape.c
parent0f475ed1a387e37d477fd434c06ad5783c58adea (diff)
downloadsamba-651d5a89c59c107c05e789358624058e16af1b66.tar.gz
samba-651d5a89c59c107c05e789358624058e16af1b66.tar.xz
samba-651d5a89c59c107c05e789358624058e16af1b66.zip
r21889: * Pull from SAMBA-3_0_25 svn r21888
* Set version to 3.0.25pre2
Diffstat (limited to 'source/lib/ldap_escape.c')
-rw-r--r--source/lib/ldap_escape.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/source/lib/ldap_escape.c b/source/lib/ldap_escape.c
index 26230884341..8907399be4a 100644
--- a/source/lib/ldap_escape.c
+++ b/source/lib/ldap_escape.c
@@ -89,3 +89,47 @@ char *escape_ldap_string_alloc(const char *s)
*p = '\0';
return output;
}
+
+char *escape_rdn_val_string_alloc(const char *s)
+{
+ char *output, *p;
+
+ /* The maximum size of the escaped string can be twice the actual size */
+ output = (char *)SMB_MALLOC(2*strlen(s) + 1);
+
+ if (output == NULL) {
+ return NULL;
+ }
+
+ p = output;
+
+ while (*s)
+ {
+ switch (*s)
+ {
+ case ',':
+ case '=':
+ case '+':
+ case '<':
+ case '>':
+ case '#':
+ case ';':
+ case '\\':
+ case '\"':
+ *p++ = '\\';
+ *p++ = *s;
+ break;
+ default:
+ *p = *s;
+ p++;
+ }
+
+ s++;
+ }
+
+ *p = '\0';
+
+ /* resize the string to the actual final size */
+ output = (char *)SMB_REALLOC(output, strlen(output) + 1);
+ return output;
+}