summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2010-09-14 14:45:45 -0700
committerJeremy Allison <jra@samba.org>2010-09-14 14:48:50 -0700
commit55b315094ef8a8ed691f9717c28cab301e17ef25 (patch)
treeb3cebf0bba50890e61917d2a1a251da53df16410
parent15abd86d54c582edfec29dfd55c256b6565da569 (diff)
downloadsamba-55b315094ef8a8ed691f9717c28cab301e17ef25.tar.gz
samba-55b315094ef8a8ed691f9717c28cab301e17ef25.tar.bz2
samba-55b315094ef8a8ed691f9717c28cab301e17ef25.zip
Fix string_to_sid() to allow non '\0' termination of the string - allows
string_to_sid() to be used in formatted strings like FOO/S-1-5-XXXX-YYYY/BAR. Jeremy.
-rw-r--r--libcli/security/dom_sid.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/libcli/security/dom_sid.c b/libcli/security/dom_sid.c
index 373f4ae175..93f887134e 100644
--- a/libcli/security/dom_sid.c
+++ b/libcli/security/dom_sid.c
@@ -109,12 +109,12 @@ bool string_to_sid(struct dom_sid *sidout, const char *sidstr)
/* BIG NOTE: this function only does SIDS where the identauth is not >= 2^32 */
uint32_t conv;
+ ZERO_STRUCTP(sidout);
+
if ((sidstr[0] != 'S' && sidstr[0] != 's') || sidstr[1] != '-') {
goto format_error;
}
- ZERO_STRUCTP(sidout);
-
/* Get the revision number. */
p = sidstr + 2;
@@ -137,11 +137,8 @@ bool string_to_sid(struct dom_sid *sidout, const char *sidstr)
conv = (uint32_t) strtoul(q, &q, 10);
if (!q) {
goto format_error;
- } else if (*q == '\0') {
- /* Just id_auth, no subauths */
- } else if (*q != '-') {
- goto format_error;
}
+
/* identauth in decimal should be < 2^32 */
/* NOTE - the conv value is in big-endian format. */
sidout->id_auth[0] = 0;
@@ -152,7 +149,8 @@ bool string_to_sid(struct dom_sid *sidout, const char *sidstr)
sidout->id_auth[5] = (conv & 0x000000ff);
sidout->num_auths = 0;
- if (*q == '\0') {
+ if (*q != '-') {
+ /* Just id_auth, no subauths */
return true;
}
@@ -176,11 +174,8 @@ bool string_to_sid(struct dom_sid *sidout, const char *sidstr)
}
q = end;
- if (*q == '\0') {
- break;
- }
if (*q != '-') {
- goto format_error;
+ break;
}
q += 1;
}