mirror of
https://github.com/samba-team/samba.git
synced 2025-08-05 12:22:11 +03:00
s3: Make string_to_sid survive the LOCAL-string_to_sid test
This commit is contained in:
@ -225,27 +225,33 @@ bool string_to_sid(DOM_SID *sidout, const char *sidstr)
|
|||||||
uint32 conv;
|
uint32 conv;
|
||||||
|
|
||||||
if ((sidstr[0] != 'S' && sidstr[0] != 's') || sidstr[1] != '-') {
|
if ((sidstr[0] != 'S' && sidstr[0] != 's') || sidstr[1] != '-') {
|
||||||
DEBUG(3,("string_to_sid: Sid %s does not start with 'S-'.\n", sidstr));
|
goto format_error;
|
||||||
return False;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ZERO_STRUCTP(sidout);
|
ZERO_STRUCTP(sidout);
|
||||||
|
|
||||||
/* Get the revision number. */
|
/* Get the revision number. */
|
||||||
p = sidstr + 2;
|
p = sidstr + 2;
|
||||||
|
|
||||||
|
if (!isdigit(*p)) {
|
||||||
|
goto format_error;
|
||||||
|
}
|
||||||
|
|
||||||
conv = (uint32) strtoul(p, &q, 10);
|
conv = (uint32) strtoul(p, &q, 10);
|
||||||
if (!q || (*q != '-')) {
|
if (!q || (*q != '-')) {
|
||||||
DEBUG(3,("string_to_sid: Sid %s is not in a valid format.\n", sidstr));
|
goto format_error;
|
||||||
return False;
|
|
||||||
}
|
}
|
||||||
sidout->sid_rev_num = (uint8) conv;
|
sidout->sid_rev_num = (uint8) conv;
|
||||||
q++;
|
q++;
|
||||||
|
|
||||||
|
if (!isdigit(*q)) {
|
||||||
|
goto format_error;
|
||||||
|
}
|
||||||
|
|
||||||
/* get identauth */
|
/* get identauth */
|
||||||
conv = (uint32) strtoul(q, &q, 10);
|
conv = (uint32) strtoul(q, &q, 10);
|
||||||
if (!q || (*q != '-')) {
|
if (!q || (*q != '-')) {
|
||||||
DEBUG(0,("string_to_sid: Sid %s is not in a valid format.\n", sidstr));
|
goto format_error;
|
||||||
return False;
|
|
||||||
}
|
}
|
||||||
/* identauth in decimal should be < 2^32 */
|
/* identauth in decimal should be < 2^32 */
|
||||||
/* NOTE - the conv value is in big-endian format. */
|
/* NOTE - the conv value is in big-endian format. */
|
||||||
@ -259,16 +265,37 @@ bool string_to_sid(DOM_SID *sidout, const char *sidstr)
|
|||||||
q++;
|
q++;
|
||||||
sidout->num_auths = 0;
|
sidout->num_auths = 0;
|
||||||
|
|
||||||
for(conv = (uint32) strtoul(q, &q, 10);
|
while (true) {
|
||||||
q && (*q =='-' || *q =='\0') && (sidout->num_auths < MAXSUBAUTHS);
|
char *end;
|
||||||
conv = (uint32) strtoul(q, &q, 10)) {
|
|
||||||
sid_append_rid(sidout, conv);
|
|
||||||
if (*q == '\0')
|
|
||||||
break;
|
|
||||||
q++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return True;
|
if (!isdigit(*q)) {
|
||||||
|
goto format_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
conv = strtoul(q, &end, 10);
|
||||||
|
if (end == q) {
|
||||||
|
goto format_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sid_append_rid(sidout, conv)) {
|
||||||
|
DEBUG(3, ("Too many sid auths in %s\n", sidstr));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
q = end;
|
||||||
|
if (*q == '\0') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (*q != '-') {
|
||||||
|
goto format_error;
|
||||||
|
}
|
||||||
|
q += 1;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
format_error:
|
||||||
|
DEBUG(3, ("string_to_sid: SID %s is not in a valid format\n", sidstr));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************
|
/*****************************************************************
|
||||||
|
Reference in New Issue
Block a user