diff options
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/smbldap.c | 8 | ||||
-rw-r--r-- | source3/lib/util_str.c | 26 |
2 files changed, 22 insertions, 12 deletions
diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c index 6f9ecb1a31..662a5a948a 100644 --- a/source3/lib/smbldap.c +++ b/source3/lib/smbldap.c @@ -292,14 +292,6 @@ ATTRIB_MAP_ENTRY sidmap_attr_list[] = { return True; } - bool smbldap_get_single_pstring (LDAP * ldap_struct, LDAPMessage * entry, - const char *attribute, pstring value) -{ - return smbldap_get_single_attribute(ldap_struct, entry, - attribute, value, - sizeof(pstring)); -} - char * smbldap_talloc_single_attribute(LDAP *ldap_struct, LDAPMessage *entry, const char *attribute, TALLOC_CTX *mem_ctx) diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 6d429e3719..68b06a6d90 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -1187,14 +1187,17 @@ void pstring_sub(char *s,const char *pattern,const char *insert) } /** - Similar to string_sub, but it will accept only allocated strings + Similar to string_sub2, but it will accept only allocated strings and may realloc them so pay attention at what you pass on no pointers inside strings, no pstrings or const may be passed as string. **/ -char *realloc_string_sub(char *string, const char *pattern, - const char *insert) +char *realloc_string_sub2(char *string, + const char *pattern, + const char *insert, + bool remove_unsafe_characters, + bool allow_trailing_dollar) { char *p, *in; char *s; @@ -1221,10 +1224,18 @@ char *realloc_string_sub(char *string, const char *pattern, case '\'': case ';': case '$': + /* allow a trailing $ + * (as in machine accounts) */ + if (allow_trailing_dollar && (i == li - 1 )) { + break; + } case '%': case '\r': case '\n': - in[i] = '_'; + if ( remove_unsafe_characters ) { + in[i] = '_'; + break; + } default: /* ok */ break; @@ -1254,6 +1265,13 @@ char *realloc_string_sub(char *string, const char *pattern, return string; } +char *realloc_string_sub(char *string, + const char *pattern, + const char *insert) +{ + return realloc_string_sub2(string, pattern, insert, true, false); +} + /* * Internal guts of talloc_string_sub and talloc_all_string_sub. * 'filter' differentiates between them. |