r20795: dom_sid_parse_talloc() gets an null terminated string as input,
authorStefan Metzmacher <metze@samba.org>
Mon, 15 Jan 2007 09:02:58 +0000 (09:02 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:43:30 +0000 (14:43 -0500)
the SDDL string has the sid strings embedded, so we need to create
a null terminated string...

metze
(This used to be commit 532395a18db84affa8a743b995e9fae2e3c312f2)

source4/libcli/security/sddl.c

index 14dd7e0917cecf49abdf3d9ff4f13bf71dbb60ef..423ccc92e9aed777fc88314c2e3db9ba9392365e 100644 (file)
@@ -100,9 +100,17 @@ static struct dom_sid *sddl_decode_sid(TALLOC_CTX *mem_ctx, const char **sddlp,
 
        /* see if its in the numeric format */
        if (strncmp(sddl, "S-", 2) == 0) {
+               struct dom_sid *sid;
+               char *sid_str;
                size_t len = strspn(sddl+2, "-0123456789");
+               sid_str = talloc_strndup(mem_ctx, sddl, len+2);
+               if (!sid_str) {
+                       return NULL;
+               }
                (*sddlp) += len+2;
-               return dom_sid_parse_talloc(mem_ctx, sddl);
+               sid = dom_sid_parse_talloc(mem_ctx, sid_str);
+               talloc_free(sid_str);
+               return sid;
        }
 
        /* now check for one of the special codes */