Fix 'magic' numbers to be strlen(something)
authorWilco Baan Hofman <wilco@baanhofman.nl>
Mon, 24 May 2010 17:53:12 +0000 (19:53 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sun, 20 Jun 2010 15:19:12 +0000 (17:19 +0200)
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
source4/lib/policy/gp_filesys.c
source4/lib/policy/gp_ldap.c

index 6248d401e7631f7ae5331b13c115be5051efdc9e..aab1d02c3b12385ed9317ade990035fa6e82f581 100644 (file)
@@ -346,6 +346,7 @@ NTSTATUS gp_create_gpt(struct gp_context *gp_ctx, const char *name, const char *
        int rv;
        int fd;
        NTSTATUS status;
+       const char *file_content = "[General]\r\nVersion=0\r\n";
 
        /* Create a forked memory context, as a base for everything here */
        mem_ctx = talloc_new(gp_ctx);
@@ -388,8 +389,8 @@ NTSTATUS gp_create_gpt(struct gp_context *gp_ctx, const char *name, const char *
                return NT_STATUS_UNSUCCESSFUL;
        }
 
-       rv = write(fd, "[General]\r\nVersion=0\r\n", 23);
-       if (rv != 23) {
+       rv = write(fd, file_content, strlen(file_content));
+       if (rv != strlen(file_content)) {
                DEBUG(0, ("Short write in GPT.INI\n"));
                talloc_free(mem_ctx);
                return NT_STATUS_UNSUCCESSFUL;
index 0c307085cb5a1c3ba56697de1a86052fed778e56..d03ea0430ba6c9eccf87bad904816d033eb768be 100644 (file)
@@ -302,12 +302,13 @@ static NTSTATUS parse_gplink (TALLOC_CTX *mem_ctx, const char *gplink_str, struc
        int pos;
        struct gp_link **gplinks;
        char *buf, *end;
+       const char *gplink_start = "[LDAP://";
 
        gplinks = talloc_array(mem_ctx, struct gp_link *, 1);
        gplinks[0] = NULL;
 
        /* Assuming every gPLink starts with "[LDAP://" */
-       start = 8;
+       start = strlen(gplink_start);
 
        for (pos = start; pos < strlen(gplink_str); pos++) {
                if (gplink_str[pos] == ';') {
@@ -329,7 +330,7 @@ static NTSTATUS parse_gplink (TALLOC_CTX *mem_ctx, const char *gplink_str, struc
                        /* Increment the array index, the string position past
                           the next "[LDAP://", and set the start reference */
                        idx++;
-                       pos += 9;
+                       pos += strlen(gplink_start)+1;
                        start = pos;
                }
        }