Skip to content

ldap: base64-encode LDIF values beginning with colon or less-than - #22339

Closed
alhudz wants to merge 1 commit into
curl:masterfrom
alhudz:ldap-ldif-safe-init-char
Closed

alhudz wants to merge 1 commit into
curl:masterfrom
alhudz:ldap-ldif-safe-init-char

Conversation

@alhudz

@alhudz alhudz commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Repro: an ldap:// reply carrying an attribute value whose first byte is : or < (both printable) is written to the client as \tattr: :value.
Cause: ldap_value_needs_base64() in ldap.c and the inline check in oldap_recv() in openldap.c base64 a value that holds a control byte or leading/trailing blank, but not one that begins with : or <. RFC 2849 excludes both from SAFE-INIT-CHAR, so the unencoded line is not valid LDIF and ldapsearch base64s these.
Fix: treat a leading : or < as needing base64 in both backends.

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.
@dfandrich dfandrich added the LDAP label Jul 20, 2026
@bagder bagder closed this in 2ba2fe3 Aug 20, 2026
@bagder

bagder commented Aug 20, 2026

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants