1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

some smbtorture hacks (random IPC calls)

(This used to be commit b32a346a1c)
This commit is contained in:
Andrew Tridgell 1998-08-25 06:42:09 +00:00
parent 2c065107b1
commit 085c66aea5
2 changed files with 65 additions and 9 deletions

View File

@ -348,11 +348,11 @@ BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, int pipe_name_len,
/****************************************************************************
call a remote api
****************************************************************************/
static BOOL cli_api(struct cli_state *cli,
char *param, int prcnt, int mprcnt,
char *data, int drcnt, int mdrcnt,
char **rparam, int *rprcnt,
char **rdata, int *rdrcnt)
BOOL cli_api(struct cli_state *cli,
char *param, int prcnt, int mprcnt,
char *data, int drcnt, int mdrcnt,
char **rparam, int *rprcnt,
char **rdata, int *rdrcnt)
{
cli_send_trans(cli,SMBtrans,
PIPE_LANMAN,strlen(PIPE_LANMAN), /* Name, length */

View File

@ -71,7 +71,9 @@ static BOOL open_connection(struct cli_state *c)
return False;
}
if (!cli_send_tconX(c, share, "A:", password, strlen(password)+1)) {
if (!cli_send_tconX(c, share,
strstr(share,"IPC$")?"IPC":"A:",
password, strlen(password)+1)) {
printf("%s refused tree connect (%s)\n", host, cli_errstr(c));
cli_shutdown(c);
return False;
@ -230,7 +232,7 @@ static void run_torture(int numops)
static void run_locktest1(void)
{
static struct cli_state cli1, cli2;
char *fname = "\\locktest.lck";
char *fname = "\\lockt1.lck";
int fnum1, fnum2, fnum3;
time_t t1, t2;
@ -355,7 +357,7 @@ static void run_locktest1(void)
static void run_locktest2(void)
{
static struct cli_state cli;
char *fname = "\\locktest.lck";
char *fname = "\\lockt2.lck";
int fnum1, fnum2, fnum3;
if (!open_connection(&cli)) {
@ -458,7 +460,7 @@ static void run_locktest2(void)
static void run_locktest3(int numops)
{
static struct cli_state cli1, cli2;
char *fname = "\\locktest.lck";
char *fname = "\\lockt3.lck";
int fnum1, fnum2, i;
uint32 offset;
@ -605,6 +607,57 @@ static void run_unlinktest(void)
printf("unlink test finished\n");
}
/* generate a random buffer */
void rand_buf(char *buf, int len)
{
while (len--) {
*buf = random();
buf++;
}
}
/* send random IPC commands */
static void run_randomipc(void)
{
char *rparam = NULL;
char *rdata = NULL;
int rdrcnt,rprcnt;
pstring param;
int api, param_len, i;
static struct cli_state cli;
struct {
int api, level;
char *format;
char *subformat;
int len;
} foo;
printf("starting random ipc test\n");
if (!open_connection(&cli)) {
return;
}
for (i=0;i<1000;i++) {
api = random() % 500;
param_len = random() % 64;
rand_buf(param, param_len);
SSVAL(param,0,api);
cli_api(&cli,
param, param_len, 8,
NULL, 0, BUFFER_SIZE,
&rparam, &rprcnt,
&rdata, &rdrcnt);
}
close_connection(&cli);
printf("finished random ipc test\n");
}
static void browse_callback(char *sname, uint32 stype, char *comment)
@ -613,6 +666,7 @@ static void browse_callback(char *sname, uint32 stype, char *comment)
}
/*
This test checks the browse list code
@ -912,6 +966,8 @@ static void create_procs(int nprocs, int numops)
printf("host=%s share=%s user=%s myname=%s\n",
host, share, username, myname);
run_randomipc();
start_timer();
create_procs(nprocs, numops);
printf("rw_torture: %g secs\n", end_timer());