diff options
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util_sid.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c index 009cc7742a..d35e8a8ac9 100644 --- a/source3/lib/util_sid.c +++ b/source3/lib/util_sid.c @@ -375,20 +375,26 @@ const char *sid_string_static(DOM_SID *sid) BOOL string_to_sid(DOM_SID *sidout, const char *sidstr) { pstring tok; - const char *p = sidstr; + char *p; /* BIG NOTE: this function only does SIDS where the identauth is not >= 2^32 */ uint32 ia; + + if (StrnCaseCmp( sidstr, "S-", 2)) { + DEBUG(0,("string_to_sid: Sid %s does not start with 'S-'.\n", sidstr)); + return False; + } memset((char *)sidout, '\0', sizeof(DOM_SID)); - if (StrnCaseCmp( sidstr, "S-", 2)) { - DEBUG(0,("string_to_sid: Sid %s does not start with 'S-'.\n", sidstr)); + p = strdup(sidstr + 2); + if (p == NULL) { + DEBUG(0, ("string_to_sid: out of memory!\n")); return False; } - p += 2; if (!next_token(&p, tok, "-", sizeof(tok))) { DEBUG(0,("string_to_sid: Sid %s is not in a valid format.\n", sidstr)); + SAFE_FREE(p); return False; } @@ -397,6 +403,7 @@ BOOL string_to_sid(DOM_SID *sidout, const char *sidstr) if (!next_token(&p, tok, "-", sizeof(tok))) { DEBUG(0,("string_to_sid: Sid %s is not in a valid format.\n", sidstr)); + SAFE_FREE(p); return False; } @@ -422,6 +429,7 @@ BOOL string_to_sid(DOM_SID *sidout, const char *sidstr) sid_append_rid(sidout, (uint32)strtoul(tok, NULL, 10)); } + SAFE_FREE(p); return True; } |