]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/dn.c
silence warning
[openldap] / servers / slapd / dn.c
index 151d6d35cee0ee66e37c2791952ef72408d0be63..5da22ac6a44a6f834e4c42eb5bbc03e8d93a3415 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -1002,7 +1002,6 @@ dnRelativeMatch(
 
                *matchp = match;
                return LDAP_SUCCESS;
-
        }
 
        if( mr == slap_schema.si_mr_dnSuperiorMatch ) {
@@ -1098,6 +1097,10 @@ rdnMatch(
  * dnParent - dn's parent, in-place
  * note: the incoming dn is assumed to be normalized/prettyfied,
  * so that escaped rdn/ava separators are in '\'+hexpair form
+ *
+ * note: "dn" and "pdn" can point to the same berval;
+ * beware that, in this case, the pointer to the original buffer
+ * will get lost.
  */
 void
 dnParent( 
@@ -1119,8 +1122,8 @@ dnParent(
        p++;
 
        assert( ATTR_LEADCHAR( p[ 0 ] ) );
-       pdn->bv_val = p;
        pdn->bv_len = dn->bv_len - (p - dn->bv_val);
+       pdn->bv_val = p;
 
        return;
 }
@@ -1299,7 +1302,7 @@ build_new_dn( struct berval * new_dn,
        new_dn->bv_len = parent_dn->bv_len + newrdn->bv_len + 1;
        new_dn->bv_val = (char *) slap_sl_malloc( new_dn->bv_len + 1, memctx );
 
-       ptr = lutil_strcopy( new_dn->bv_val, newrdn->bv_val );
+       ptr = lutil_strncopy( new_dn->bv_val, newrdn->bv_val, newrdn->bv_len );
        *ptr++ = ',';
        strcpy( ptr, parent_dn->bv_val );
 }