s3-util_sid Accept S-1-5 as a SID
authorAndrew Bartlett <abartlet@samba.org>
Sat, 4 Sep 2010 04:05:30 +0000 (14:05 +1000)
committerJeremy Allison <jra@samba.org>
Tue, 14 Sep 2010 21:48:48 +0000 (14:48 -0700)
source3/lib/util_sid.c

index 58df0f2a486175e43b9f9a93fac22d62050b990e..9a2876baece534510dd3c6c5397e98d4366c47fc 100644 (file)
@@ -230,8 +230,12 @@ bool string_to_sid(struct dom_sid *sidout, const char *sidstr)
        }
 
        /* get identauth */
-       if (!q || (*q != '-')) {
        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 */
@@ -243,8 +247,12 @@ bool string_to_sid(struct dom_sid *sidout, const char *sidstr)
        sidout->id_auth[4] = (conv & 0x0000ff00) >> 8;
        sidout->id_auth[5] = (conv & 0x000000ff);
 
-       q++;
        sidout->num_auths = 0;
+       if (*q == '\0') {
+               return true;
+       }
+
+       q++;
 
        while (true) {
                char *end;