From 4cee58780cb15fe5889b9dd0dc34459512d75062 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 23 Nov 1998 21:51:05 +0000 Subject: unix instance of group database API (This used to be commit e76f593b3572ac881f1aa1fb3326d8b7169b0078) --- source3/lib/util.c | 17 +++++++++++++---- source3/lib/util_sid.c | 11 +++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index 7247e95c64..ad5dbcf106 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -189,6 +189,18 @@ char *Atoic(char *p, int *n, char *c) return p; } +int* add_num_to_list(uint32 **num, int *count, int val) +{ + (*num) = Realloc((*num), ((*count)+1) * sizeof(uint32)); + if ((*num) == NULL) + { + return NULL; + } + (*num)[(*count)] = val; + (*count)++; + + return (*num); +} /************************************************************************* reads a list of numbers *************************************************************************/ @@ -206,13 +218,10 @@ char *get_numlist(char *p, uint32 **num, int *count) while ((p = Atoic(p, &val, ":,")) != NULL && (*p) != ':') { - (*num) = Realloc((*num), ((*count)+1) * sizeof(uint32)); - if ((*num) == NULL) + if (add_num_to_list(num, count, val) == NULL) { return NULL; } - (*num)[(*count)] = val; - (*count)++; p++; } diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c index 9ca3a59ad4..cce360f4c1 100644 --- a/source3/lib/util_sid.c +++ b/source3/lib/util_sid.c @@ -43,7 +43,7 @@ char *sid_to_string(pstring sidstr_out, DOM_SID *sid) for (i = 0; i < sid->num_auths; i++) { - slprintf(subauth, sizeof(subauth)-1, "-%d", sid->sub_auths[i]); + slprintf(subauth, sizeof(subauth)-1, "-%u", sid->sub_auths[i]); pstrcat(sidstr_out, subauth); } @@ -103,7 +103,9 @@ BOOL string_to_sid(DOM_SID *sidout, char *sidstr) * NOTE - the subauths are in native machine-endian format. They * are converted to little-endian when linearized onto the wire. */ - sid_append_rid(sidout, atoi(tok)); + uint32 rid = (uint32)strtoul(tok, NULL, 10); + DEBUG(50,("string_to_sid: tok: %s rid 0x%x\n", tok, rid)); + sid_append_rid(sidout, rid); } DEBUG(7,("string_to_sid: converted SID %s ok\n", sidstr)); @@ -145,6 +147,11 @@ void sid_copy(DOM_SID *sid1, DOM_SID *sid2) { int i; + for (i = 0; i < 6; i++) + { + sid1->id_auth[i] = sid2->id_auth[i]; + } + for (i = 0; i < sid2->num_auths; i++) { sid1->sub_auths[i] = sid2->sub_auths[i]; -- cgit