s3-torture Add tests to show that the dom_sid parsing was faulty.
authorAndrew Bartlett <abartlet@samba.org>
Sat, 4 Sep 2010 04:13:31 +0000 (14:13 +1000)
committerJeremy Allison <jra@samba.org>
Tue, 14 Sep 2010 21:48:49 +0000 (14:48 -0700)
Andrew Bartlett

source3/torture/torture.c

index 806455ff18be975c9ab39bdc3e16abbc8e5d14b7..06ed264debc63e4d21e7a17b768ffc6e17447130 100644 (file)
@@ -6859,6 +6859,103 @@ static bool run_local_string_to_sid(int dummy) {
        return true;
 }
 
+static bool run_local_binary_to_sid(int dummy) {
+       struct dom_sid *sid = talloc(NULL, struct dom_sid);
+       static const char good_binary_sid[] = {
+               0x1, /* revision number */
+               15, /* num auths */
+               0x1, 0x1, 0x1, 0x1, 0x1, 0x1, /* id_auth */
+               0x1, 0x1, 0x1, 0x1, /* auth[0] */
+               0x1, 0x1, 0x1, 0x1, /* auth[1] */
+               0x1, 0x1, 0x1, 0x1, /* auth[2] */
+               0x1, 0x1, 0x1, 0x1, /* auth[3] */
+               0x1, 0x1, 0x1, 0x1, /* auth[4] */
+               0x1, 0x1, 0x1, 0x1, /* auth[5] */
+               0x1, 0x1, 0x1, 0x1, /* auth[6] */
+               0x1, 0x1, 0x1, 0x1, /* auth[7] */
+               0x1, 0x1, 0x1, 0x1, /* auth[8] */
+               0x1, 0x1, 0x1, 0x1, /* auth[9] */
+               0x1, 0x1, 0x1, 0x1, /* auth[10] */
+               0x1, 0x1, 0x1, 0x1, /* auth[11] */
+               0x1, 0x1, 0x1, 0x1, /* auth[12] */
+               0x1, 0x1, 0x1, 0x1, /* auth[13] */
+               0x1, 0x1, 0x1, 0x1, /* auth[14] */
+       };
+
+       static const char long_binary_sid[] = {
+               0x1, /* revision number */
+               15, /* num auths */
+               0x1, 0x1, 0x1, 0x1, 0x1, 0x1, /* id_auth */
+               0x1, 0x1, 0x1, 0x1, /* auth[0] */
+               0x1, 0x1, 0x1, 0x1, /* auth[1] */
+               0x1, 0x1, 0x1, 0x1, /* auth[2] */
+               0x1, 0x1, 0x1, 0x1, /* auth[3] */
+               0x1, 0x1, 0x1, 0x1, /* auth[4] */
+               0x1, 0x1, 0x1, 0x1, /* auth[5] */
+               0x1, 0x1, 0x1, 0x1, /* auth[6] */
+               0x1, 0x1, 0x1, 0x1, /* auth[7] */
+               0x1, 0x1, 0x1, 0x1, /* auth[8] */
+               0x1, 0x1, 0x1, 0x1, /* auth[9] */
+               0x1, 0x1, 0x1, 0x1, /* auth[10] */
+               0x1, 0x1, 0x1, 0x1, /* auth[11] */
+               0x1, 0x1, 0x1, 0x1, /* auth[12] */
+               0x1, 0x1, 0x1, 0x1, /* auth[13] */
+               0x1, 0x1, 0x1, 0x1, /* auth[14] */
+               0x1, 0x1, 0x1, 0x1, /* auth[15] */
+               0x1, 0x1, 0x1, 0x1, /* auth[16] */
+               0x1, 0x1, 0x1, 0x1, /* auth[17] */
+       };
+
+       static const char long_binary_sid2[] = {
+               0x1, /* revision number */
+               32, /* num auths */
+               0x1, 0x1, 0x1, 0x1, 0x1, 0x1, /* id_auth */
+               0x1, 0x1, 0x1, 0x1, /* auth[0] */
+               0x1, 0x1, 0x1, 0x1, /* auth[1] */
+               0x1, 0x1, 0x1, 0x1, /* auth[2] */
+               0x1, 0x1, 0x1, 0x1, /* auth[3] */
+               0x1, 0x1, 0x1, 0x1, /* auth[4] */
+               0x1, 0x1, 0x1, 0x1, /* auth[5] */
+               0x1, 0x1, 0x1, 0x1, /* auth[6] */
+               0x1, 0x1, 0x1, 0x1, /* auth[7] */
+               0x1, 0x1, 0x1, 0x1, /* auth[8] */
+               0x1, 0x1, 0x1, 0x1, /* auth[9] */
+               0x1, 0x1, 0x1, 0x1, /* auth[10] */
+               0x1, 0x1, 0x1, 0x1, /* auth[11] */
+               0x1, 0x1, 0x1, 0x1, /* auth[12] */
+               0x1, 0x1, 0x1, 0x1, /* auth[13] */
+               0x1, 0x1, 0x1, 0x1, /* auth[14] */
+               0x1, 0x1, 0x1, 0x1, /* auth[15] */
+               0x1, 0x1, 0x1, 0x1, /* auth[16] */
+               0x1, 0x1, 0x1, 0x1, /* auth[17] */
+               0x1, 0x1, 0x1, 0x1, /* auth[18] */
+               0x1, 0x1, 0x1, 0x1, /* auth[19] */
+               0x1, 0x1, 0x1, 0x1, /* auth[20] */
+               0x1, 0x1, 0x1, 0x1, /* auth[21] */
+               0x1, 0x1, 0x1, 0x1, /* auth[22] */
+               0x1, 0x1, 0x1, 0x1, /* auth[23] */
+               0x1, 0x1, 0x1, 0x1, /* auth[24] */
+               0x1, 0x1, 0x1, 0x1, /* auth[25] */
+               0x1, 0x1, 0x1, 0x1, /* auth[26] */
+               0x1, 0x1, 0x1, 0x1, /* auth[27] */
+               0x1, 0x1, 0x1, 0x1, /* auth[28] */
+               0x1, 0x1, 0x1, 0x1, /* auth[29] */
+               0x1, 0x1, 0x1, 0x1, /* auth[30] */
+               0x1, 0x1, 0x1, 0x1, /* auth[31] */
+       };
+
+       if (!sid_parse(good_binary_sid, sizeof(good_binary_sid), sid)) {
+               return false;
+       }
+       if (sid_parse(long_binary_sid2, sizeof(long_binary_sid2), sid)) {
+               return false;
+       }
+       if (sid_parse(long_binary_sid, sizeof(long_binary_sid), sid)) {
+               return false;
+       }
+       return true;
+}
+
 /* Split a path name into filename and stream name components. Canonicalise
  * such that an implicit $DATA token is always explicit.
  *
@@ -7591,6 +7688,7 @@ static struct {
        { "LOCAL-STREAM-NAME", run_local_stream_name, 0},
        { "LOCAL-WBCLIENT", run_local_wbclient, 0},
        { "LOCAL-string_to_sid", run_local_string_to_sid, 0},
+       { "LOCAL-binary_to_sid", run_local_binary_to_sid, 0},
        { "LOCAL-DBTRANS", run_local_dbtrans, 0},
        { "LOCAL-TEVENT-SELECT", run_local_tevent_select, 0},
        {NULL, NULL, 0}};