1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-28 07:21:54 +03:00

string_to_sid was using next_token() this is bad as it stops you from

being able to use next_token() outside of string_to_sid calls.
use strchr instead
(This used to be commit 1c478ca172)
This commit is contained in:
Luke Leighton 1998-12-02 16:01:40 +00:00
parent 87f4eea109
commit 137f9c7042

View File

@ -57,60 +57,61 @@ char *sid_to_string(pstring sidstr_out, const DOM_SID *sid)
BOOL string_to_sid(DOM_SID *sidout, const char *sidstr) BOOL string_to_sid(DOM_SID *sidout, const char *sidstr)
{ {
pstring tok; const char *p = sidstr;
const char *p = sidstr; /* BIG NOTE: this function only does SIDS where the identauth is not >= 2^32 */
/* BIG NOTE: this function only does SIDS where the identauth is not >= 2^32 */ uint32 ia;
uint32 ia;
memset((char *)sidout, '\0', sizeof(DOM_SID)); memset((char *)sidout, '\0', sizeof(DOM_SID));
if (StrnCaseCmp( sidstr, "S-", 2)) { if (StrnCaseCmp( sidstr, "S-", 2))
DEBUG(0,("string_to_sid: Sid %s does not start with 'S-'.\n", sidstr)); {
return False; DEBUG(0,("string_to_sid: Sid %s does not start with 'S-'.\n", sidstr));
} return False;
}
p += 2; if ((p = strchr(p, '-')) == NULL)
if (!next_token(&p, tok, "-", sizeof(tok))) { {
DEBUG(0,("string_to_sid: Sid %s is not in a valid format.\n", sidstr)); DEBUG(0,("string_to_sid: Sid %s is not in a valid format.\n", sidstr));
return False; return False;
} }
/* Get the revision number. */ p++;
sidout->sid_rev_num = (uint8)strtoul(tok,NULL,10);
if (!next_token(&p, tok, "-", sizeof(tok))) { /* Get the revision number. */
DEBUG(0,("string_to_sid: Sid %s is not in a valid format.\n", sidstr)); sidout->sid_rev_num = (uint8)strtoul(p,NULL,10);
return False;
}
/* identauth in decimal should be < 2^32 */ if ((p = strchr(p, '-')) == NULL)
ia = (uint32)strtoul(tok,NULL,10); {
DEBUG(0,("string_to_sid: Sid %s is not in a valid format.\n", sidstr));
return False;
}
/* NOTE - the ia value is in big-endian format. */ p++;
sidout->id_auth[0] = 0;
sidout->id_auth[1] = 0;
sidout->id_auth[2] = (ia & 0xff000000) >> 24;
sidout->id_auth[3] = (ia & 0x00ff0000) >> 16;
sidout->id_auth[4] = (ia & 0x0000ff00) >> 8;
sidout->id_auth[5] = (ia & 0x000000ff);
sidout->num_auths = 0; /* identauth in decimal should be < 2^32 */
ia = (uint32)strtoul(p,NULL,10);
while(next_token(&p, tok, "-", sizeof(tok)) && /* NOTE - the ia value is in big-endian format. */
sidout->num_auths < MAXSUBAUTHS) sidout->id_auth[0] = 0;
{ sidout->id_auth[1] = 0;
/* sidout->id_auth[2] = (ia & 0xff000000) >> 24;
* NOTE - the subauths are in native machine-endian format. They sidout->id_auth[3] = (ia & 0x00ff0000) >> 16;
* are converted to little-endian when linearized onto the wire. sidout->id_auth[4] = (ia & 0x0000ff00) >> 8;
*/ sidout->id_auth[5] = (ia & 0x000000ff);
uint32 rid = (uint32)strtoul(tok, NULL, 10);
DEBUG(50,("string_to_sid: tok: %s rid 0x%lx\n", tok, (unsigned long)rid));
sid_append_rid(sidout, rid);
}
DEBUG(7,("string_to_sid: converted SID %s ok\n", sidstr)); sidout->num_auths = 0;
return True; while (((p = strchr(p, '-')) != NULL) && sidout->num_auths < MAXSUBAUTHS)
{
p++;
/*
* NOTE - the subauths are in native machine-endian format. They
* are converted to little-endian when linearized onto the wire.
*/
sid_append_rid(sidout, (uint32)strtoul(p, NULL, 10));
}
return True;
} }
/***************************************************************** /*****************************************************************