mirror of
https://github.com/curl/curl.git
synced 2026-07-31 07:58:04 +03:00
ldap: base64-encode LDIF values beginning with colon or less-than
A value whose first byte is ':' or '<' is not a SAFE-INIT-CHAR per RFC 2849 and must be base64-encoded, but ldap_value_needs_base64() and the inline check in oldap_recv() only encoded on a control byte or leading/trailing blank. Such a value was emitted verbatim, producing LDIF that strict parsers reject.
This commit is contained in:
parent
33dc64fd0e
commit
51c2d881ff
2 changed files with 8 additions and 4 deletions
|
|
@ -238,8 +238,10 @@ static bool ldap_value_needs_base64(const char *attr, size_t attr_len,
|
|||
if((attr_len > 7) && curl_strequal(";binary", attr + attr_len - 7))
|
||||
return TRUE;
|
||||
|
||||
/* check for leading or trailing whitespace */
|
||||
if(val->bv_len && (ISBLANK(val->bv_val[0]) ||
|
||||
/* check for a leading ':' or '<' (not a SAFE-INIT-CHAR per RFC 2849) or
|
||||
leading or trailing whitespace */
|
||||
if(val->bv_len && ((val->bv_val[0] == ':') || (val->bv_val[0] == '<') ||
|
||||
ISBLANK(val->bv_val[0]) ||
|
||||
ISBLANK(val->bv_val[val->bv_len - 1])))
|
||||
return TRUE;
|
||||
|
||||
|
|
|
|||
|
|
@ -1206,9 +1206,11 @@ static CURLcode oldap_recv(struct Curl_easy *data, int sockindex, char *buf,
|
|||
break;
|
||||
|
||||
if(!binary) {
|
||||
/* check for leading or trailing whitespace */
|
||||
/* check for a leading ':' or '<' (not a SAFE-INIT-CHAR per RFC
|
||||
2849) or leading or trailing whitespace */
|
||||
if(bvals[i].bv_len &&
|
||||
(ISBLANK(bvals[i].bv_val[0]) ||
|
||||
((bvals[i].bv_val[0] == ':') || (bvals[i].bv_val[0] == '<') ||
|
||||
ISBLANK(bvals[i].bv_val[0]) ||
|
||||
ISBLANK(bvals[i].bv_val[bvals[i].bv_len - 1])))
|
||||
binval = TRUE;
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue