Closed Bug 529728 Opened 15 years ago Closed 14 years ago

DNs with trailing escaped spaces not handled correctly in ldap_explode

Categories

(Directory :: LDAP C SDK, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: nkinder, Assigned: nkinder)

Details

Attachments

(1 file)

Attached patch Proposed PatchSplinter Review
If you call ldap_explode_dn() on a DN string with a properly escaped space at the end of an RDN, the space is trimmed off of the RDN value.  The space should be treated as a part of the value since it is escaped as defined in RFC 4514.

Here is an example from a test program using:

  8	    dns = ldap_explode_dn("ou=1234ABC\\ ,ou=people,o=airius.com", 0 );
  (gdb) n
  10	    return rc;
  (gdb) p dns[0]
  $1 = 0x601060 "ou=1234ABC\\"
  (gdb) p dns[1]
  $2 = 0x601080 "ou=people"
  (gdb) p dns[2]
  $3 = 0x6010a0 "o=airius.com"
  (gdb) p dns[3]
  $4 = 0x0

The attached patch first checks if a trailing space is preceded by an escape ('\\') character before trimming it.  Here is the same test program in a debugger with the attached patch:

  8	    dns = ldap_explode_dn("ou=1234ABC\\ ,ou=people,o=airius.com", 0 );
  (gdb) n
  10	    return rc;
  (gdb) p dns[0]
  $1 = 0x601060 "ou=1234ABC\\ "

This example with the attached patch demonstrates that unescaped trailing spaces will still be trimmed so we can handle LDAPv2 style DNs (where a space is allowed between the RDNs):

  8	    dns = ldap_explode_dn("ou=1234ABC\\  ,ou=people,o=airius.com", 0 );
  (gdb) n
  10	    return rc;
  (gdb) p dns[0]
  $1 = 0x601060 "ou=1234ABC\\ "
Attachment #413265 - Flags: review+
Comment on attachment 413265 [details] [diff] [review]
Proposed Patch

This should probably have review from richm.
Attachment #413265 - Attachment is patch: true
Attachment #413265 - Flags: review?(richm)
Attachment #413265 - Flags: review?(richm) → review+
Flagging for checkin, I'll do this soon.
Keywords: checkin-needed
Checked into the new repository:

http://hg.mozilla.org/projects/ldap-sdks/rev/50db1cc0a72b
Assignee: nobody → nkinder
Status: NEW → RESOLVED
Closed: 14 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: