r7410: minor cleanup
authorDerrell Lipman <derrell@samba.org>
Wed, 8 Jun 2005 20:30:50 +0000 (20:30 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:17:51 +0000 (13:17 -0500)
(This used to be commit 4c8bffc3f01d60ef7d8b75e92f4d062326288f4c)

source4/lib/ldb/common/ldb_explode_dn.c
source4/lib/ldb/include/ldb_explode_dn.h

index db8e8f2a85b78dd55485e520e0d6742e92d9137a..4e71bc70d144735a771b08295210539629c5b55c 100644 (file)
@@ -386,10 +386,9 @@ ldb_explode_dn(void *mem_ctx,
                                dest++;
                        }
                        src = component->attributes[i]->rdn;
-                       do {
-                               *(dest++) = *(src++);
-                       } while(*src);
-                       *dest = '\0';
+
+                        /* we are guaranteed to have enough space in dest */
+                        strcpy(dest, src);
                }
 
                ldb_debug(mem_ctx,
@@ -434,15 +433,17 @@ ldb_explode_dn(void *mem_ctx,
 
         /* copy the normalized components into the DN */
        for (i = 0; i < dn->comp_num; i++) {
+
+                /* add a separator between DN components */
                if (i != 0) {
-                       *dest = ',';
-                       dest++;
+                       *dest++ = ',';
                }
+
+                /* point to this component of the DN */
                src = dn->components[i]->component;
-               do {
-                       *(dest++) = *(src++);
-               } while(*src);
-               *dest = '\0';
+
+                /* we are guaranteed to have enough space in dest */
+                strcpy(dest, src);
        }
 
        ldb_debug(mem_ctx, LDB_DEBUG_TRACE, "dn: [%s]\n", dn->dn);
index fb34be8b87f4517932593241f336383e576cae85..78768ebb80d1b868c4f4d4106e457cf53c734b5b 100644 (file)
@@ -32,7 +32,12 @@ struct ldb_dn_component {
 };
 
 struct ldb_dn {
-       char *dn;
-       int comp_num;
+       char *                      dn;
+       int                         comp_num;
        struct ldb_dn_component **  components;
 };
+
+
+extern struct ldb_dn *
+ldb_explode_dn(void *mem_ctx,
+               const char *orig_dn);