s3:winbind: Make parse_sidlist take a const char *
authorVolker Lendecke <vl@samba.org>
Sun, 2 Aug 2009 15:17:27 +0000 (17:17 +0200)
committerVolker Lendecke <vl@samba.org>
Wed, 5 Aug 2009 07:21:24 +0000 (03:21 -0400)
source3/winbindd/winbindd_async.c
source3/winbindd/winbindd_proto.h

index f53875f6171f89c7751561d74c996e1da2b0f807..094602160d96bc5cf9d9c4ab01fc478fa0a6482e 100644 (file)
@@ -632,25 +632,32 @@ bool print_sidlist(TALLOC_CTX *mem_ctx, const DOM_SID *sids,
        return True;
 }
 
-bool parse_sidlist(TALLOC_CTX *mem_ctx, char *sidstr,
+bool parse_sidlist(TALLOC_CTX *mem_ctx, const char *sidstr,
                   DOM_SID **sids, size_t *num_sids)
 {
-       char *p, *q;
+       const char *p, *q;
 
        p = sidstr;
        if (p == NULL)
                return False;
 
        while (p[0] != '\0') {
+               fstring tmp;
+               size_t sidlen;
                DOM_SID sid;
                q = strchr(p, '\n');
                if (q == NULL) {
                        DEBUG(0, ("Got invalid sidstr: %s\n", p));
                        return False;
                }
-               *q = '\0';
+               sidlen = PTR_DIFF(q, p);
+               if (sidlen >= sizeof(tmp)-1) {
+                       return false;
+               }
+               memcpy(tmp, p, sidlen);
+               tmp[sidlen] = '\0';
                q += 1;
-               if (!string_to_sid(&sid, p)) {
+               if (!string_to_sid(&sid, tmp)) {
                        DEBUG(0, ("Could not parse sid %s\n", p));
                        return False;
                }
index 08c08222a65a74f7764f65dd3ed7a32d4803b27c..220253777758c9dd6e5ac42273767cc12118cce5 100644 (file)
@@ -100,7 +100,7 @@ enum winbindd_result winbindd_dual_list_groups(struct winbindd_domain *domain,
                                                struct winbindd_cli_state *state);
 bool print_sidlist(TALLOC_CTX *mem_ctx, const DOM_SID *sids,
                   size_t num_sids, char **result, ssize_t *len);
-bool parse_sidlist(TALLOC_CTX *mem_ctx, char *sidstr,
+bool parse_sidlist(TALLOC_CTX *mem_ctx, const char *sidstr,
                   DOM_SID **sids, size_t *num_sids);
 enum winbindd_result winbindd_dual_lookuprids(struct winbindd_domain *domain,
                                              struct winbindd_cli_state *state);