summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-05-04 08:58:07 +0000
committerAndrew Tridgell <tridge@samba.org>2000-05-04 08:58:07 +0000
commit420d7e02dca5c207091ded625082b4f5df2b9c65 (patch)
tree719c92cf957103970c4e1e47cbe058eb68eb5096 /source3/utils
parentf3a861e04e33901c89408a9c89ebaa81fc606f97 (diff)
downloadsamba-420d7e02dca5c207091ded625082b4f5df2b9c65.tar.gz
samba-420d7e02dca5c207091ded625082b4f5df2b9c65.tar.bz2
samba-420d7e02dca5c207091ded625082b4f5df2b9c65.zip
an even simpler example of NT gettings its locking code wrong. This
one doesn't even need two connections to the box, just two file handles. it is a very simple case actually, and one I think will happen quite a lot in real life. I wonder how they haven't noticed it? I checked and W2K has the same bug. (This used to be commit 0b335e415818028ac0daad5f99c2fd9086a2a656)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/locktest.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/source3/utils/locktest.c b/source3/utils/locktest.c
index 0d1c1719a8..d52d023f25 100644
--- a/source3/utils/locktest.c
+++ b/source3/utils/locktest.c
@@ -38,6 +38,8 @@ static BOOL analyze;
#define LOCK_PCT 25
#define UNLOCK_PCT 65
#define RANGE_MULTIPLE 32
+#define NCONNECTIONS 2
+#define NFILES 2
struct record {
char r1, r2;
@@ -47,16 +49,10 @@ struct record {
};
static struct record preset[] = {
-#if 0
-{36, 5, 1, 1, 1, 2, 1},
-{ 2, 6, 0, 1, 0, 2, 1},
-{53, 92, 1, 1, 0, 0, 1},
-{99, 11, 1, 1, 2, 1, 1},
-#endif
-{36, 5, 1, 1, 1888, 960, 1},
-{47, 23, 0, 1, 0, 2176, 1},
-{84, 95, 1, 1, 3072, 96, 1},
-{65, 14, 0, 0, 2752, 352, 1},
+{36, 5, 0, 0, 0, 8, 1},
+{ 2, 6, 0, 1, 0, 1, 1},
+{53, 92, 0, 0, 0, 0, 1},
+{99, 11, 0, 0, 7, 1, 1},
};
static struct record *recorded;
@@ -178,12 +174,10 @@ static void reconnect(struct cli_state *cli[2][2], int fnum[2][2][2],
share[0] = share1;
share[1] = share2;
-
-
for (server=0;server<2;server++)
- for (conn=0;conn<2;conn++) {
+ for (conn=0;conn<NCONNECTIONS;conn++) {
if (cli[server][conn]) {
- for (f=0;f<2;f++) {
+ for (f=0;f<NFILES;f++) {
cli_close(cli[server][conn], fnum[server][conn][f]);
}
cli_ulogoff(cli[server][conn]);
@@ -283,8 +277,8 @@ static void close_files(struct cli_state *cli[2][2],
int server, conn, f;
for (server=0;server<2;server++)
- for (conn=0;conn<2;conn++)
- for (f=0;f<2;f++) {
+ for (conn=0;conn<NCONNECTIONS;conn++)
+ for (f=0;f<NFILES;f++) {
if (fnum[server][conn][f] != -1) {
cli_close(cli[server][conn], fnum[server][conn][f]);
fnum[server][conn][f] = -1;
@@ -300,8 +294,8 @@ static void open_files(struct cli_state *cli[2][2],
int server, conn, f;
for (server=0;server<2;server++)
- for (conn=0;conn<2;conn++)
- for (f=0;f<2;f++) {
+ for (conn=0;conn<NCONNECTIONS;conn++)
+ for (f=0;f<NFILES;f++) {
fnum[server][conn][f] = cli_open(cli[server][conn], FILENAME,
O_RDWR|O_CREAT,
DENY_NONE);
@@ -353,8 +347,8 @@ static void test_locks(char *share1, char *share2)
if (n < sizeof(preset) / sizeof(preset[0])) {
recorded[n] = preset[n];
} else {
- recorded[n].conn = random() % 2;
- recorded[n].f = random() % 2;
+ recorded[n].conn = random() % NCONNECTIONS;
+ recorded[n].f = random() % NFILES;
recorded[n].start = random() % (LOCKRANGE-1);
recorded[n].len = 1 + random() % (LOCKRANGE-recorded[n].start);
recorded[n].start *= RANGE_MULTIPLE;