From 15abd86d54c582edfec29dfd55c256b6565da569 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 4 Sep 2010 14:13:31 +1000 Subject: s3-torture Add tests to show that the dom_sid parsing was faulty. Andrew Bartlett --- source3/torture/torture.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) (limited to 'source3/torture') diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 806455ff18..06ed264deb 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -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}}; -- cgit