-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server control requests get eaten after a NULL character in the berval #40
Comments
As an aside, should 'ber_strdup_x' in liblber really be using strlen()? :) |
Yes, ber_strdup is meant for C strings and C strings are NUL-terminated, by definition. But obviously you should not be using it on values that are not C strings. Likewise you cannot use ber_str2bv, for the same reason. You should be using ber_dupbv, which is meant for bervals. |
@phillipod Want to hold 3.0.4 for this to be fixed? |
@hyc okay, makes sense about ber_strdup and ber_str2bv. But ber_dupbv seems to indicate that it is duplicating an existing struct berval to another struct berval - which seems kind of redundant when the code is trying to build a struct berval from just a chunk of memory? What about ber_mem2bv? It seems to have the right semantics of not ever using strlen unlike ber_strdup and ber_str2bv, and it doesn't require the source to be a struct berval. Keep in mind that the underlying perl representation of the input should be a SVpv with a defined length instead of a NULL-terminated string. |
@quanah actually, yeah, might as well. |
phillipod wrote:
Yeah, mem2bv should do fine. -- Howard Chu |
…als_with_nulls - Fixes #40: Server control requests get eaten after a NULL character in the berval
* New upstream release. * Fix undef comparison * Misc variable initializations to quiet warnings * Fixed sasl mechanisms initializtion * Examples cleanup * LDAPv3 extended operation support * New developer mode test suite * Fixed quanah/net-ldapapi#3: ldap_set_rebind_proc XS being called with invalid arguments from set_rebind_proc * Fixed quanah/net-ldapapi#6: ldap_sasl_bind has wrong prototype in LDAPapi.xs * Fixed quanah/net-ldapapi#8: search_s() clobbers ATTRS parameter * Fixed quanah/net-ldapapi#11: result() blocking when called with output from rename() * Fixed quanah/net-ldapapi#20: ldap_result() doesn't honour passed timeout value * Fixed quanah/net-ldapapi#21: ldap_set_option(LDAP_OPT_TIMEOUT, 1) on OpenLDAP returns -1 * Fixed quanah/net-ldapapi#28: Server control responses get eaten after a NULL character in the berval * Fixed quanah/net-ldapapi#30: ldap_search_ext() and ldap_search_ext_s() segfault when used with timeout * Fixed quanah/net-ldapapi#31: ldap_result() and ldap_url_search_st() timeout parameters have a granularity of 1 second * Fixed quanah/net-ldapapi#40: Server control requests get eaten after a NULL character in the berval * Correct merge problem with POD error. * Update standards version to 3.9.8 (no changes required). [dgit import package libnet-ldapapi-perl 3.0.4-1]
Hi,
I was looking into the syncrepl issue reported by Nat Sincheler, which I guess is the syncrepl issue you mentioned in #14. I don't think I've identified his issue, but we're definitely not handling BER correctly - in what appears to be a mirror of #28
If a berval containing an otherwise valid '\x00' byte is attempted to be passed, all data after the '\x00' byte will be discarded due to strlen() stopping at '\x00', say for instance the 'beforeCount' on a VLV control.
Using the sample code in #28, but changing 'beforeCount' to 0, I get this:
However, with the following change:
I get this output:
To sum up - does it make sense to replace the ber_strdup() with ber_str2bv() in the XS wrapper ldap_create_control() ?
As I say, I don't think this is related to the syncrepl issue - but only because I don't see how a '\x00' character could be inserted into the BER of 'mode' on the syncRequestValue....
Perhaps there is another way we should be reading the user-provided BER? Otherwise, I'm happy to prepare a pull request for this, targeting a 3.0.5 or 3.1.x release
Cheers,
Phillip
The text was updated successfully, but these errors were encountered: