Commit 448fc0e9 authored by Howard Chu's avatar Howard Chu
Browse files

For LDAPV2 results, make sure Referrals are appended to any error text

instead of replacing it.
parent 491dc61d
...@@ -18,15 +18,25 @@ ...@@ -18,15 +18,25 @@
/* we need LBER internals */ /* we need LBER internals */
#include "../../libraries/liblber/lber-int.h" #include "../../libraries/liblber/lber-int.h"
static char *v2ref( struct berval **ref ) static char *v2ref( struct berval **ref, const char *text )
{ {
size_t len, i; size_t len = 0, i = 0;
char *v2; char *v2;
if(ref == NULL) return NULL; if(ref == NULL) return (char *)text;
len = sizeof("Referral:"); if (text) {
v2 = ch_strdup("Referral:"); len = strlen( text );
if (text[len-1] != '\n')
i = 1;
}
v2 = ch_malloc( len+i+sizeof("Referral:") );
if (text) {
strcpy(v2, text);
if (i)
v2[len++] = '\n';
}
strcpy( v2+len, "Referral:" );
for( i=0; ref[i] != NULL; i++ ) { for( i=0; ref[i] != NULL; i++ ) {
v2 = ch_realloc( v2, len + ref[i]->bv_len + 1 ); v2 = ch_realloc( v2, len + ref[i]->bv_len + 1 );
...@@ -384,12 +394,15 @@ send_ldap_result( ...@@ -384,12 +394,15 @@ send_ldap_result(
err = LDAP_NO_SUCH_OBJECT; err = LDAP_NO_SUCH_OBJECT;
} else if ( op->o_protocol < LDAP_VERSION3 ) { } else if ( op->o_protocol < LDAP_VERSION3 ) {
err = LDAP_PARTIAL_RESULTS; err = LDAP_PARTIAL_RESULTS;
tmp = v2ref( ref );
text = tmp;
ref = NULL;
} }
} }
if ( op->o_protocol < LDAP_VERSION3 ) {
tmp = v2ref( ref, text );
text = tmp;
ref = NULL;
}
tag = req2res( op->o_tag ); tag = req2res( op->o_tag );
msgid = (tag != LBER_SEQUENCE) ? op->o_msgid : 0; msgid = (tag != LBER_SEQUENCE) ? op->o_msgid : 0;
...@@ -449,11 +462,9 @@ send_search_result( ...@@ -449,11 +462,9 @@ send_search_result(
err = LDAP_PARTIAL_RESULTS; err = LDAP_PARTIAL_RESULTS;
} }
tmp = v2ref( refs ); tmp = v2ref( refs, text );
text = tmp;
refs = NULL; refs = NULL;
if( tmp != NULL ) text = tmp;
} else { } else {
/* don't send references in search results */ /* don't send references in search results */
assert( refs == NULL ); assert( refs == NULL );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment