https://bugs.openldap.org/show_bug.cgi?id=9839
Issue ID: 9839 Summary: Undocumented behavior of ldap_url_parse() when port is 0 in URL string Product: OpenLDAP Version: unspecified Hardware: Other OS: Other Status: UNCONFIRMED Keywords: needs_review Severity: normal Priority: --- Component: documentation Assignee: bugs@openldap.org Reporter: jiaqing.zhao@linux.intel.com Target Milestone: ---
In ldap_url_parse(), when the port in URL string is set to 0 like "ldap://example.com:0", the output value of lud_port will be the default port (389 for LDAP, 636 for LDAPs). This behavior is undocumented.
I created a patch to illustrate this behavior. As my gitlab account is pending confirmation, I put it in the attachments.
This affects OpenLDAP 2.5.x and 2.6.x, but it is already been fixed in master branch https://git.openldap.org/openldap/openldap/-/commit/e3905c989821f6c09576988e... for issue #9596. Will it be included in 2.7.0? If so, I may need to add something like "(Until OpenLDAP 2.7.0)" before the line I added.
https://bugs.openldap.org/show_bug.cgi?id=9839
--- Comment #1 from jiaqing.zhao@linux.intel.com --- Created attachment 898 --> https://bugs.openldap.org/attachment.cgi?id=898&action=edit Proposed patch
https://bugs.openldap.org/show_bug.cgi?id=9839
--- Comment #2 from Howard Chu hyc@openldap.org --- Port=0 is meaningless for clients, so why would anyone ever run into this?
In #9596 it's done to allow slapd to listen on a dynamically assigned port. There is no use case for it anywhere else. It's also questionable whether the change for #9596 is actually appropriate.
https://bugs.openldap.org/show_bug.cgi?id=9839
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |WONTFIX Status|UNCONFIRMED |RESOLVED
--- Comment #3 from Quanah Gibson-Mount quanah@openldap.org --- This behavior should remain undocumented as a port of 0 should not be used.
https://bugs.openldap.org/show_bug.cgi?id=9839
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |VERIFIED Keywords|needs_review |
https://bugs.openldap.org/show_bug.cgi?id=9839
--- Comment #4 from Jiaqing Zhao jiaqing.zhao@linux.intel.com --- Got it. Thank you for your response
https://bugs.openldap.org/show_bug.cgi?id=9839
--- Comment #5 from Jiaqing Zhao jiaqing.zhao@linux.intel.com --- (In reply to Howard Chu from comment #2)
Port=0 is meaningless for clients, so why would anyone ever run into this?
In #9596 it's done to allow slapd to listen on a dynamically assigned port. There is no use case for it anywhere else. It's also questionable whether the change for #9596 is actually appropriate.
+1, I also think listening on a dynamically assigned port is almost useless for the slapd daemon.
Btw, invalid ports numbers like -1, 2147483648 (INT32_MAX + 1) can get parsed successfully by ldap_url_parse(). Do you think this is a bug? If so, I will submit patch for it.