* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <string.h>
+#include <ac/socket.h> /* Get struct sockaddr for slap.h */
#include "slap.h"
/*
* given a dn (or root part), return an aliased dn if any of the
* alias suffixes match
*/
-char *suffixAlias ( dn, op, be )
- char *dn;
- Operation *op;
- Backend *be;
+char *suffixAlias (char *dn, Operation *op, Backend *be)
{
int i, dnLength;
+ if(dn == NULL) return NULL;
+
dnLength = strlen ( dn );
op->o_suffix = NULL;
op->o_suffixAliased = NULL;
if (!strcasecmp(be->be_suffixAlias[i],
dn + (dnLength - aliasLength))) {
char *oldDN = dn;
- op->o_suffixAliased = strdup ( be->be_suffixAlias[i] );
+ op->o_suffixAliased = ch_strdup ( be->be_suffixAlias[i] );
dn = ch_malloc ( (dnLength - aliasLength) +
strlen (be->be_suffixAlias[ i+1 ]) + 1);
strncpy (dn, oldDN, dnLength - aliasLength);
strcpy (dn + (dnLength - aliasLength), be->be_suffixAlias[ i+1 ]);
- op->o_suffix = strdup (dn);
+ op->o_suffix = ch_strdup (dn);
Debug( LDAP_DEBUG_ARGS, "ALIAS: converted %s to %s", oldDN, dn, 0);
free (oldDN);
break;