Don't walk past the end of ldb values.
[samba.git] / source4 / libcli / security / dom_sid.c
index f5457e7e0e4bcf8d927f6fa27b5585e9eb136449..1a7519e362988095b9bb945c7556a5f37f4adceb 100644 (file)
@@ -151,6 +151,21 @@ struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr)
        return ret;
 }
 
+/*
+  convert a string to a dom_sid, returning a talloc'd dom_sid
+*/
+struct dom_sid *dom_sid_parse_length(TALLOC_CTX *mem_ctx, const DATA_BLOB *sid)
+{
+       struct dom_sid *ret;
+       char *p = talloc_strndup(mem_ctx, sid->data, sid->length);
+       if (!p) {
+               return NULL;
+       }
+       ret = dom_sid_parse_talloc(mem_ctx, p);
+       talloc_free(p);
+       return ret;
+}
+
 /*
   copy a dom_sid structure
 */