From: Peter van Dijk Date: Thu, 11 Feb 2016 09:24:25 +0000 (+0100) Subject: fix escaping X-Git-Tag: auth-4.0.0-alpha2~62^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F3359%2Fhead;p=thirdparty%2Fpdns.git fix escaping --- diff --git a/modules/ldapbackend/powerldap.cc b/modules/ldapbackend/powerldap.cc index dcb01b6769..fe910a6d7c 100644 --- a/modules/ldapbackend/powerldap.cc +++ b/modules/ldapbackend/powerldap.cc @@ -267,13 +267,24 @@ const string PowerLDAP::escape( const string& str ) { string a; string::const_iterator i; + char tmp[4]; for( i = str.begin(); i != str.end(); i++ ) { - if( *i == '*' || *i == '\\' ) { - a += '\\'; - } - a += *i; + // RFC4515 3 + if( *i == '*' || + *i == '(' || + *i == ')' || + *i == '\\' || + *i == '\0' || + *i > 127) + { + sprintf(tmp,"\\%02x", (unsigned char)*i); + + a += tmp; + } + else + a += *i; } return a;